From d8ec48c6d6f4c62df34c2489658ee9b893311120 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 10 Feb 2016 09:14:38 +0300 Subject: [PATCH] validation: update sm_array_overflow.c After warning the first time then we assume the value is in bounds. Apparently it only works for arrays so only the c[i] and d[i] usages turn off the warnings. Signed-off-by: Dan Carpenter --- validation/sm_array_overflow.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/validation/sm_array_overflow.c b/validation/sm_array_overflow.c index 9ca4194b..ad73ec66 100644 --- a/validation/sm_array_overflow.c +++ b/validation/sm_array_overflow.c @@ -12,6 +12,7 @@ static int options_write(void) char *str3; char *str4; char *str5; + unsigned int j = 4; str3 = str2; str4 = str; @@ -25,25 +26,25 @@ static int options_write(void) a[i] = 42; b[i] = '\0'; c[i] = '\0'; - d[i] = '\0'; - str[i] = '\0'; - str2[i] = '\0'; - str3[i] = '\0'; - str4[i] = '\0'; - str5[i] = '\0'; + str[j] = '\0'; + str2[j] = '\0'; + str3[j] = '\0'; + str4[j] = '\0'; + str5[j] = '\0'; + d[j] = '\0'; } /* * check-name: smatch array check * check-command: smatch --spammy sm_array_overflow.c * * check-output-start -sm_array_overflow.c:25 options_write() error: buffer overflow 'a' 4 <= 4 -sm_array_overflow.c:26 options_write() error: buffer overflow 'b' 4 <= 4 -sm_array_overflow.c:27 options_write() error: buffer overflow 'c' 4 <= 4 -sm_array_overflow.c:28 options_write() error: buffer overflow 'd' 4 <= 4 +sm_array_overflow.c:26 options_write() error: buffer overflow 'a' 4 <= 4 +sm_array_overflow.c:27 options_write() error: buffer overflow 'b' 4 <= 4 +sm_array_overflow.c:28 options_write() error: buffer overflow 'c' 4 <= 4 sm_array_overflow.c:29 options_write() error: buffer overflow 'str' 4 <= 4 sm_array_overflow.c:30 options_write() error: buffer overflow 'str2' 4 <= 4 sm_array_overflow.c:31 options_write() error: buffer overflow 'str3' 4 <= 4 sm_array_overflow.c:32 options_write() error: buffer overflow 'str4' 4 <= 4 +sm_array_overflow.c:34 options_write() error: buffer overflow 'd' 4 <= 4 * check-output-end */ -- 2.11.4.GIT