[Lsb-messages] /var/www/bzr/lsb/devel/build_env r1947: Fix memory corruption in lsbcc on large lib path (bug 3492)

Denis Silakov denis.silakov at rosalab.ru
Sat May 5 18:50:16 UTC 2012


------------------------------------------------------------
revno: 1947
committer: Denis Silakov <denis.silakov at rosalab.ru>
branch nick: build_env
timestamp: Sat 2012-05-05 22:50:16 +0400
message:
  Fix memory corruption in lsbcc on large lib path (bug 3492)
modified:
  lsbdev-cc/lsbcc.c
-------------- next part --------------
=== modified file 'lsbdev-cc/lsbcc.c'
--- a/lsbdev-cc/lsbcc.c	2012-04-23 14:48:53 +0000
+++ b/lsbdev-cc/lsbcc.c	2012-05-05 18:50:16 +0000
@@ -849,13 +849,13 @@
 	    if (num_ents == ents_available) {
 		if (*dirents != NULL) {
 		    struct dirent **tmpdirents = *dirents;
-		    *dirents = malloc(ents_available + 1024);
-		    memcpy(*dirents, tmpdirents, ents_available);
+		    *dirents = malloc(ents_available * sizeof(struct dirent*) + 1024);
+		    memcpy(*dirents, tmpdirents, ents_available * sizeof(struct dirent*));
 		    free(tmpdirents);
 		} else {
 		    *dirents = malloc(1024);
 		}
-		ents_available += 1024;
+		ents_available += 1024 / sizeof(struct dirent*);
 	    }
 	    (*dirents)[num_ents] = malloc(sizeof(struct dirent));
 	    if (!(*dirents)[num_ents]) {



More information about the lsb-messages mailing list