Skip to content

Commit da90b86

Browse files
committed
Check for array bounds limit while parsing pid length string
Ensure we never get an array overflow, fixes a potential issue found by static analysis. Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent ddfa629 commit da90b86

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

faultstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static int pid_max_digits(void)
244244

245245
buf[n] = '\0';
246246
max_digits = 0;
247-
while (buf[max_digits] >= '0' && buf[max_digits] <= '9')
247+
while ((max_digits < n) && (buf[max_digits] >= '0') && (buf[max_digits] <= '9'))
248248
max_digits++;
249249
if (max_digits < min_digits)
250250
max_digits = min_digits;

0 commit comments

Comments
 (0)