mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #6147 from dearblue/memsearch
Fixed buffer overflow in `mrb_memsearch()`
This commit is contained in:
+1
-1
@@ -499,7 +499,7 @@ mrb_memsearch(const void *x0, mrb_int m, const void *y0, mrb_int n)
|
||||
const unsigned char *ye = ys+n-m+1;
|
||||
|
||||
for (;;) {
|
||||
y = (const unsigned char*)memchr(y, x[0], (size_t)(ye-ys));
|
||||
y = (const unsigned char*)memchr(y, x[0], (size_t)(ye-y));
|
||||
if (y == NULL) return -1;
|
||||
if (memcmp(x, y, m) == 0) {
|
||||
return (mrb_int)(y - ys);
|
||||
|
||||
Reference in New Issue
Block a user