aboutsummaryrefslogtreecommitdiff
path: root/src/test_spellfix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-03-01 01:07:17 +0000
committerdrh <drh@noemail.net>2013-03-01 01:07:17 +0000
commit503a686e09ce03995eef5d9a95ef217532575be5 (patch)
tree11602fc697bab83aa85d31324c8abb24189560c8 /src/test_spellfix.c
parent016fff2b6eacbf1335e105f430bcd741d771d7f4 (diff)
downloadsqlite-503a686e09ce03995eef5d9a95ef217532575be5.tar.gz
sqlite-503a686e09ce03995eef5d9a95ef217532575be5.zip
Always use strncmp() rather than memcmp() when comparing strings where one
or other string might be less than the length parameter, since optimized versions of memcmp() might read past the first difference and in so doing generate an access violation. FossilOrigin-Name: d73435587ba7459e2e2c32980d0e17abdeceb4bc
Diffstat (limited to 'src/test_spellfix.c')
-rw-r--r--src/test_spellfix.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/test_spellfix.c b/src/test_spellfix.c
index f294f48c6..16376244a 100644
--- a/src/test_spellfix.c
+++ b/src/test_spellfix.c
@@ -744,22 +744,22 @@ static int utf8Len(unsigned char c, int N){
}
/*
-** Return TRUE (non-zero) of the To side of the given cost matches
+** Return TRUE (non-zero) if the To side of the given cost matches
** the given string.
*/
static int matchTo(EditDist3Cost *p, const char *z, int n){
if( p->nTo>n ) return 0;
- if( memcmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0;
+ if( strncmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0;
return 1;
}
/*
-** Return TRUE (non-zero) of the To side of the given cost matches
+** Return TRUE (non-zero) if the From side of the given cost matches
** the given string.
*/
static int matchFrom(EditDist3Cost *p, const char *z, int n){
assert( p->nFrom<=n );
- if( memcmp(p->a, z, p->nFrom)!=0 ) return 0;
+ if( strncmp(p->a, z, p->nFrom)!=0 ) return 0;
return 1;
}
@@ -1952,7 +1952,7 @@ static int spellfix1Init(
);
}
for(i=3; rc==SQLITE_OK && i<argc; i++){
- if( memcmp(argv[i],"edit_cost_table=",16)==0 && pNew->zCostTable==0 ){
+ if( strncmp(argv[i],"edit_cost_table=",16)==0 && pNew->zCostTable==0 ){
pNew->zCostTable = spellfix1Dequote(&argv[i][16]);
if( pNew->zCostTable==0 ) rc = SQLITE_NOMEM;
continue;
@@ -2681,7 +2681,7 @@ static int spellfix1Update(
p->pConfig3 = 0;
return SQLITE_OK;
}
- if( memcmp(zCmd,"edit_cost_table=",16)==0 ){
+ if( strncmp(zCmd,"edit_cost_table=",16)==0 ){
editDist3ConfigDelete(p->pConfig3);
p->pConfig3 = 0;
sqlite3_free(p->zCostTable);