diff options
author | Anatol Belski <ab@php.net> | 2014-07-02 10:27:59 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-07-02 10:27:59 +0200 |
commit | 84876850ff3e50ee7b85abc7261bdf9038d65e4b (patch) | |
tree | 091e7474679a1b6700459d6db2e36e0ac9272397 /ext/mysqlnd/mysqlnd_charset.c | |
parent | 0e7bf92129f608c44f4d5bd51139ec2bd85fecc8 (diff) | |
parent | 96783bdfb79b33646dc916d4b93bc33b78d70c4c (diff) | |
download | php-git-84876850ff3e50ee7b85abc7261bdf9038d65e4b.tar.gz |
Merge remote-tracking branch 'origin/str_size_and_int64_56_backport' into str_size_and_int64
* origin/str_size_and_int64_56_backport: (178 commits)
fix integer overflow in {stream,file}_{get,put}_contents()
add some missing NEWS entries
NEWS block for 5.6.0RC3
Fix ext/pgsql builds with libpq < 7.3.
updated libs_version.txt
updated libs_version.txt
updated libmagic.patch in 5.6+
updated libmagic.patch
Fixed possible crash because of race conditions on modifying constants in shared memory
remove the NEWS entry for the reverted fpm fix
remove the NEWS entry for the reverted fpm fix
remove the NEWS entry for the reverted fpm fix
Revert "Fix Bug #67530 error_log=syslog ignored"
--enable-fpm for the travis build
fix the last fpm NEWS entry, the other bug is related, but not the same what we fixed here
NEWS
NEWS
Fix bug #67091: make install fails to install libphp5.so on FreeBSD 10.0
adding NEWS entry for the fix for bug #65641
Updated NEWS file for recent phpdbg fixes
...
Diffstat (limited to 'ext/mysqlnd/mysqlnd_charset.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_charset.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c index 41b0f33894..fa97b877e5 100644 --- a/ext/mysqlnd/mysqlnd_charset.c +++ b/ext/mysqlnd/mysqlnd_charset.c @@ -418,20 +418,60 @@ static uint mysqlnd_mbcharlen_utf16(unsigned int utf16) /* {{{ utf32 functions */ -static uint -check_mb_utf32(const char *start __attribute((unused)), const char *end __attribute((unused))) +static unsigned int check_mb_utf32(const char *start __attribute((unused)), const char *end __attribute((unused))) { return 4; } -static uint -mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unused))) +static unsigned int mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unused))) { return 4; } /* }}} */ + +/* {{{ gb18030 functions */ +#define is_gb18030_odd(c) (0x81 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0xFE) +#define is_gb18030_even_2(c) ((0x40 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0x7E) || (0x80 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0xFE)) +#define is_gb18030_even_4(c) (0x30 <= (zend_uchar) (c) && (zend_uchar) (c) <= 0x39) + + +static unsigned int mysqlnd_mbcharlen_gb18030(unsigned int c) +{ + if (c <= 0xFF) { + return !is_gb18030_odd(c); + } + if (c > 0xFFFF || !is_gb18030_odd((c >> 8) & 0xFF)) { + return 0; + } + if (is_gb18030_even_2((c & 0xFF))) { + return 2; + } + if (is_gb18030_even_4((c & 0xFF))) { + return 4; + } + + return 0; +} + + +static unsigned int my_ismbchar_gb18030(const char * start, const char * end) +{ + if (end - start <= 1 || !is_gb18030_odd(start[0])) { + return 0; + } + + if (is_gb18030_even_2(start[1])) { + return 2; + } else if (end - start > 3 && is_gb18030_even_4(start[1]) && is_gb18030_odd(start[2]) && is_gb18030_even_4(start[3])) { + return 4; + } + + return 0; +} +/* }}} */ + /* The server compiles sometimes the full utf-8 (the mb4) as utf8m4, and the old as utf8, for BC reasons. Sometimes, utf8mb4 is just utf8 but the old charsets are utf8mb3. @@ -643,6 +683,8 @@ const MYSQLND_CHARSET mysqlnd_charsets[] = { 245, UTF8_MB4, UTF8_MB4"_croatian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid}, { 246, UTF8_MB4, UTF8_MB4"_unicode_520_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid}, { 247, UTF8_MB4, UTF8_MB4"_vietnamese_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid}, + { 248, "gb18030", "gb18030_chinese_ci", 1, 4, "", mysqlnd_mbcharlen_gb18030, my_ismbchar_gb18030}, + { 249, "gb18030", "gb18030_bin", 1, 4, "", mysqlnd_mbcharlen_gb18030, my_ismbchar_gb18030}, { 254, UTF8_MB3, UTF8_MB3"_general_cs", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid}, { 0, NULL, NULL, 0, 0, NULL, NULL, NULL} |