Fix memory overflow bugs
authorJens Axboe <jens.axboe@oracle.com>
Thu, 19 Jul 2007 12:50:05 +0000 (14:50 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 19 Jul 2007 12:50:05 +0000 (14:50 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c
parse.c

diff --git a/init.c b/init.c
index f0aa5e3b01375c4f1eb395e1b2e77bd8565501e4..93322fdcc266bf065153f576b7e8204b7da3035d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -564,8 +564,12 @@ static int parse_jobs_ini(char *file, int stonewall_flag)
        }
 
        string = malloc(4096);
-       name = malloc(256);
-       memset(name, 0, 256);
+
+       /*
+        * it's really 256 + small bit, 280 should suffice
+        */
+       name = malloc(280);
+       memset(name, 0, 280);
 
        stonewall = stonewall_flag;
        do {
diff --git a/parse.c b/parse.c
index 9015b1d72bd5a527ef36ed0db12646ce01fcc945..f0e644f113bf63171fbebc8e0bd2545ae5d0fcd8 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -159,8 +159,8 @@ void strip_blank_end(char *p)
        if (s)
                p = s;
 
-       s = p + strlen(p) - 1;
-       while (isspace(*s) || iscntrl(*s))
+       s = p + strlen(p);
+       while ((isspace(*s) || iscntrl(*s)) && (s > p))
                s--;
 
        *(s + 1) = '\0';