Skip to content

Commit 4b8c4e6

Browse files
authored
Merge pull request #148 from visitorckw/fix-strncmp
Fix potential out-of-bounds access in strncmp()
2 parents c56c590 + 529d827 commit 4b8c4e6

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ int strncmp(char *s1, char *s2, int len)
7171
return -1;
7272
if (s1[i] > s2[i])
7373
return 1;
74+
if (!s1[i])
75+
return 0;
7476
i++;
7577
}
7678
return 0;

tests/snapshots/fib.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/snapshots/hello.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)