summaryrefslogtreecommitdiff
path: root/dev-libs/oniguruma/files/oniguruma-6.9.3-fix-heap-buffer-overflow-php78633.patch
blob: e946a57d648fc5a02374f8c1ebd2e190be37d2c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
https://bugs.php.net/bug.php?id=78633
https://github.com/kkos/oniguruma/commit/15c4228aa2ffa02140a99912dd3177df0b1841c6

--- a/src/regcomp.c
+++ b/src/regcomp.c
@@ -734,8 +734,8 @@ add_compile_string(UChar* s, int mb_len, int str_len,
     COP(reg)->exact_n.s = p;
   }
   else {
+    xmemset(COP(reg)->exact.s, 0, sizeof(COP(reg)->exact.s));
     xmemcpy(COP(reg)->exact.s, s, (size_t )byte_len);
-    COP(reg)->exact.s[byte_len] = '\0';
   }
 
   return 0;
--- a/src/regexec.c
+++ b/src/regexec.c
@@ -2889,6 +2889,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
           DATA_ENSURE(0);
           q = lowbuf;
           while (len-- > 0) {
+            if (ps >= endp) goto fail;
             if (*ps != *q) goto fail;
             ps++; q++;
           }