File: regex-stack-overflow.diff

package info (click to toggle)
dietlibc 0.34~cvs20160606-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,768 kB
  • sloc: ansic: 71,692; asm: 13,008; cpp: 1,860; makefile: 817; sh: 300; perl: 62
file content (23 lines) | stat: -rw-r--r-- 841 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Description: fix regex stack overflow
 this only caused an FTBFS due to a testsuite failure on alpha
 but overwrote the stack on any architecture
Author: mirabilos <tg@debian.org>
Applied-Upstream: yes

--- a/libregex/rx.c
+++ b/libregex/rx.c
@@ -344,11 +344,11 @@ static int matchpiece(void*__restrict__
   unsigned int *offsets;
   assert(a->max>0 && a->max<1000);
 #ifdef DEBUG
-  printf("alloca(%d)\n",sizeof(int)*a->max);
+  printf("alloca(%d)\n",sizeof(int)*(a->max+1));
 #endif
-  offsets=alloca(sizeof(int)*a->max);
+  offsets=alloca(sizeof(int)*(a->max+1));
   offsets[0]=0;
-//  printf("allocating %d offsets...\n",a->max);
+//  printf("allocating %d offsets...\n",a->max+1);
 //  printf("matchpiece \"%s\"...\n",s);
   /* first, try to match the atom as often as possible, up to a->max times */
   if (a->max == 1 && a->min == 1)