Fossil SCM

Change a memcmp into a strncmp in regexp.c in order to avoid the possibility of a buffer overread with optimized memcmp implementations.

drh 2013-03-01 01:15 trunk
Commit eec7c001f51f28c5ebf4a3a5beb3b4c4f6a982c6
1 file changed +1 -1
+1 -1
--- src/regexp.c
+++ src/regexp.c
@@ -197,11 +197,11 @@
197197
198198
/* Look for the initial prefix match, if there is one. */
199199
if( pRe->nInit ){
200200
unsigned char x = pRe->zInit[0];
201201
while( in.i+pRe->nInit<=in.mx
202
- && (zIn[in.i]!=x || memcmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0)
202
+ && (zIn[in.i]!=x || strncmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0)
203203
){
204204
in.i++;
205205
}
206206
if( in.i+pRe->nInit>in.mx ) return 0;
207207
}
208208
--- src/regexp.c
+++ src/regexp.c
@@ -197,11 +197,11 @@
197
198 /* Look for the initial prefix match, if there is one. */
199 if( pRe->nInit ){
200 unsigned char x = pRe->zInit[0];
201 while( in.i+pRe->nInit<=in.mx
202 && (zIn[in.i]!=x || memcmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0)
203 ){
204 in.i++;
205 }
206 if( in.i+pRe->nInit>in.mx ) return 0;
207 }
208
--- src/regexp.c
+++ src/regexp.c
@@ -197,11 +197,11 @@
197
198 /* Look for the initial prefix match, if there is one. */
199 if( pRe->nInit ){
200 unsigned char x = pRe->zInit[0];
201 while( in.i+pRe->nInit<=in.mx
202 && (zIn[in.i]!=x || strncmp(zIn+in.i, pRe->zInit, pRe->nInit)!=0)
203 ){
204 in.i++;
205 }
206 if( in.i+pRe->nInit>in.mx ) return 0;
207 }
208

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button