Skip to content

Commit 79fdf90

Browse files
Avoid reading out-of-bounds in pm_strnstr
Fixes #3738.
1 parent f242682 commit 79fdf90

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/prism.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22620,8 +22620,11 @@ static const char *
2262022620
pm_strnstr(const char *big, const char *little, size_t big_length) {
2262122621
size_t little_length = strlen(little);
2262222622

22623-
for (const char *big_end = big + big_length; big < big_end; big++) {
22623+
22624+
while (big_length >= little_length) {
2262422625
if (*big == *little && memcmp(big, little, little_length) == 0) return big;
22626+
big_length--;
22627+
big++;
2262522628
}
2262622629

2262722630
return NULL;

0 commit comments

Comments
 (0)