]> granicus.if.org Git - php/commitdiff
- Fixed bad xor in signed types due to integer promotion.
authorGustavo André dos Santos Lopes <cataphract@php.net>
Mon, 5 Sep 2011 00:39:39 +0000 (00:39 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Mon, 5 Sep 2011 00:39:39 +0000 (00:39 +0000)
- Replaced undefined signed overflow with char -> unsigned char conversion.

ext/mysqlnd/mysqlnd_charset.c

index a87b2a1f4f52297686b49324ca705f9c7ae1eb30..0b7ce08236b46c764c870e192c179794b6f00572 100644 (file)
@@ -123,11 +123,11 @@ static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
                  [F4][80..8F][80..BF][80..BF]
                */
 
-               if (!((start[1] ^ 0x80) < 0x40 &&
-                       (start[2] ^ 0x80) < 0x40 &&
-                       (start[3] ^ 0x80) < 0x40 &&
-                               (c >= 0xf1 || start[1] >= (char)0x90) &&
-                               (c <= 0xf3 || start[1] <= (char)0x8F)))
+               if (!(((zend_uchar)start[1] ^ 0x80) < 0x40 &&
+                       ((zend_uchar)start[2] ^ 0x80) < 0x40 &&
+                       ((zend_uchar)start[3] ^ 0x80) < 0x40 &&
+                               (c >= 0xf1 || (zend_uchar)start[1] >= 0x90) &&
+                               (c <= 0xf3 || (zend_uchar)start[1] <= 0x8F)))
                {
                        return 0;       /* invalid utf8 character */
                }