From 273255103bfd88d5129ffd2a3c009b54a2300b4b Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 30 Jan 2013 15:55:47 +0100 Subject: [PATCH] LU-2709 build: fix 'memory corruption' errors 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 Change-Id: Iabc9bd7609d285a3709737748f2100b90769d795 Reviewed-on: http://review.whamcloud.com/5210 Tested-by: Hudson Reviewed-by: Keith Mannthey Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Oleg Drokin --- lnet/utils/routerstat.c | 2 +- lustre/utils/lr_reader.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lnet/utils/routerstat.c b/lnet/utils/routerstat.c index 2baa759..f31f811 100644 --- a/lnet/utils/routerstat.c +++ b/lnet/utils/routerstat.c @@ -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"); diff --git a/lustre/utils/lr_reader.c b/lustre/utils/lr_reader.c index 84346e1..fe95b3b 100644 --- a/lustre/utils/lr_reader.c +++ b/lustre/utils/lr_reader.c @@ -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); -- 1.8.3.1