aboutsummaryrefslogtreecommitdiff
path: root/src/func.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-06-13 12:19:21 +0000
committerdrh <drh@noemail.net>2011-06-13 12:19:21 +0000
commit0a32fa6d8150d8b5399a87d6c3ee7a679ee241a6 (patch)
tree45e2bbab28b06472bfea16c6eac6426a8d8c49b7 /src/func.c
parent7006c18e0043a2787b763e7fa7f3a0df964fe5cf (diff)
downloadsqlite-0a32fa6d8150d8b5399a87d6c3ee7a679ee241a6.tar.gz
sqlite-0a32fa6d8150d8b5399a87d6c3ee7a679ee241a6.zip
Use only unsigned values in the implementatin of LIKE and GLOB so that
values won't overflow to negative when dealing with malformed UTF8. FossilOrigin-Name: 77f01578bb565d1bc884b374b68bae10ce34a084
Diffstat (limited to 'src/func.c')
-rw-r--r--src/func.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/func.c b/src/func.c
index 0b9b600d7..407ea26aa 100644
--- a/src/func.c
+++ b/src/func.c
@@ -506,10 +506,10 @@ struct compareInfo {
** whereas only characters less than 0x80 do in ASCII.
*/
#if defined(SQLITE_EBCDIC)
-# define sqlite3Utf8Read(A,C) (*(A++))
-# define GlogUpperToLower(A) A = sqlite3UpperToLower[A]
+# define sqlite3Utf8Read(A,C) (*(A++))
+# define GlogUpperToLower(A) A = sqlite3UpperToLower[A]
#else
-# define GlogUpperToLower(A) if( A<0x80 ){ A = sqlite3UpperToLower[A]; }
+# define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; }
#endif
static const struct compareInfo globInfo = { '*', '?', '[', 0 };
@@ -552,9 +552,9 @@ static int patternCompare(
const u8 *zPattern, /* The glob pattern */
const u8 *zString, /* The string to compare against the glob */
const struct compareInfo *pInfo, /* Information about how to do the compare */
- const int esc /* The escape character */
+ u32 esc /* The escape character */
){
- int c, c2;
+ u32 c, c2;
int invert;
int seen;
u8 matchOne = pInfo->matchOne;
@@ -684,7 +684,7 @@ static void likeFunc(
sqlite3_value **argv
){
const unsigned char *zA, *zB;
- int escape = 0;
+ u32 escape = 0;
int nPat;
sqlite3 *db = sqlite3_context_db_handle(context);