Whamcloud - gitweb
LU-2709 build: fix 'memory corruption' errors
authorSebastien Buisson <sebastien.buisson@bull.net>
Wed, 30 Jan 2013 14:55:47 +0000 (15:55 +0100)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Jan 2013 05:18:21 +0000 (00:18 -0500)
Fix 'memory corruption' defects found by Coverity version 6.5.0:
Out-of-bounds access (OVERRUN_STATIC)
Overrunning static array by passing it to a
function which indexes it at a higher byte position.
Unbounded source buffer (STRING_SIZE)
Passing string of unknown size to a function that expects
a string of a particular size.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: Iabc9bd7609d285a3709737748f2100b90769d795
Reviewed-on: http://review.whamcloud.com/5210
Tested-by: Hudson
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/routerstat.c
lustre/utils/lr_reader.c

index 2baa759..f31f811 100644 (file)
@@ -106,7 +106,7 @@ do_stat (int fd)
 
    lseek (fd, 0, SEEK_SET);
    now = timenow();
-   n = read (fd, buffer, sizeof (buffer));
+   n = read(fd, buffer, sizeof(buffer) - 1);
    if (n < 0)
    {
       fprintf (stderr, "Can't read statfile\n");
index 84346e1..fe95b3b 100644 (file)
@@ -192,8 +192,8 @@ int main(int argc, char *const argv[])
                /* If neither is set, we're pre-1.4.6, make a guess. */
                /* Construct debugfs command line. */
                memset(cmd, 0, sizeof(cmd));
-               sprintf(cmd, "%s -c -R 'rdump /%s %s' %s",
-                       DEBUGFS, MDT_LOGS_DIR, tmpdir, dev);
+               snprintf(cmd, sizeof(cmd), "%s -c -R 'rdump /%s %s' %s",
+                        DEBUGFS, MDT_LOGS_DIR, tmpdir, dev);
 
                run_command(cmd);