Enhance the sqlite3_strglob() and sqlite3_strlike() interfaces so that they
will do sensible things with NULL string pointers. This is an extra layer of defense against bugs such as reported by [forum:/forumpost/730b554179|forum post 730b554179]. FossilOrigin-Name: 8ba9c884bded52e3e044ff39c826c04838e7c31f05d802f4a14d9ce5a01ab721
This commit is contained in:
+14
-2
@@ -823,7 +823,13 @@ static int patternCompare(
|
||||
** non-zero if there is no match.
|
||||
*/
|
||||
int sqlite3_strglob(const char *zGlobPattern, const char *zString){
|
||||
return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');
|
||||
if( zString==0 ){
|
||||
return zGlobPattern!=0;
|
||||
}else if( zGlobPattern==0 ){
|
||||
return 1;
|
||||
}else {
|
||||
return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -831,7 +837,13 @@ int sqlite3_strglob(const char *zGlobPattern, const char *zString){
|
||||
** a miss - like strcmp().
|
||||
*/
|
||||
int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){
|
||||
return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);
|
||||
if( zStr==0 ){
|
||||
return zPattern!=0;
|
||||
}else if( zPattern==0 ){
|
||||
return 1;
|
||||
}else{
|
||||
return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user