Skip to content

Commit 026140b

Browse files
stevenjohnstonematzbot
authored andcommitted
[ruby/prism] Avoid reading out-of-bounds in pm_strnstr
Fixes ruby/prism#3738. ruby/prism@37bb46ff5f
1 parent 2870b7d commit 026140b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

prism/prism.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22639,7 +22639,7 @@ static const char *
2263922639
pm_strnstr(const char *big, const char *little, size_t big_length) {
2264022640
size_t little_length = strlen(little);
2264122641

22642-
for (const char *big_end = big + big_length; big < big_end; big++) {
22642+
for (const char *max = big + big_length - little_length; big <= max; big++) {
2264322643
if (*big == *little && memcmp(big, little, little_length) == 0) return big;
2264422644
}
2264522645

0 commit comments

Comments
 (0)