svn: /php/php-src/ branches/PHP_5_3/ext/mysqli/tests/bug54674.phpt branches/PHP_5_3/ext/mysqlnd/mysqlnd_charset.c trunk/ext/mysqli/tests/bug54674.phpt
trunk/ext/mysqlnd/mysqlnd_charset.c
| From: | Andrey Hristov | Date: | Mon, 09 May 2011 16:20:35 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/mysqli/tests/bug54674.phpt branches/PHP_5_3/ext/mysqlnd/mysqlnd_charset.c trunk/ext/mysqli/tests/bug54674.phpt trunk/ext/mysqlnd/mysqlnd_charset.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64890@lists.php.net to get a copy of this message | ||
andrey Mon, 09 May 2011 16:20:35 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310856
Log:
Fix for bug 54674..typo in the check of SJIS
Bug: http://bugs.php.net/54674 (Assigned) mysqlnd
valid_sjis_(head|tail) is using invalid operator and range.
Changed paths:
A php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug54674.phpt
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_charset.c
A php/php-src/trunk/ext/mysqli/tests/bug54674.phpt
U php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c
Added: php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug54674.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug54674.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/bug54674.phpt 2011-05-09 16:20:35 UTC (rev 310856)
@@ -0,0 +1,31 @@
+--TEST--
+Bug #54674 mysqlnd valid_sjis_(head|tail) is using invalid operator and range.
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--INI--
+mysqli.max_links = 1
+mysqli.allow_persistent = Off
+mysqli.max_persistent = 0
+mysqli.reconnect = Off
+--FILE--
+<?php
+ include ("connect.inc");
+
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(),
mysqli_connect_error());
+ }
+
+ $japanese_so = pack('H4', '835c');
+ $link->set_charset('sjis');
+ var_dump($link->real_escape_string($japanese_so) === $japanese_so);
+ mysqli_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+bool(true)
+done!
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_charset.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_charset.c 2011-05-09 15:34:46 UTC (rev 310855)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_charset.c 2011-05-09 16:20:35 UTC (rev 310856)
@@ -325,11 +325,9 @@
/* }}} */
-/* {{{ sjis functions */
-#define valid_sjis_head(c) ((0x81 <= (c) && (c) <= 0x9F) && \
- (0xE0 <= (c) && (c) <= 0xFC))
-#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) && \
- (0x80 <= (c) && (c) <= 0x7C))
+/* {{{ functions */
+#define valid_sjis_head(c) ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c)
&& (c) <= 0xFC))
+#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c)
&& (c) <= 0x7C))
static unsigned int check_mb_sjis(const char *start, const char *end)
Added: php/php-src/trunk/ext/mysqli/tests/bug54674.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/bug54674.phpt (rev 0)
+++ php/php-src/trunk/ext/mysqli/tests/bug54674.phpt 2011-05-09 16:20:35 UTC (rev 310856)
@@ -0,0 +1,31 @@
+--TEST--
+Bug #54674 mysqlnd valid_sjis_(head|tail) is using invalid operator and range.
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--INI--
+mysqli.max_links = 1
+mysqli.allow_persistent = Off
+mysqli.max_persistent = 0
+mysqli.reconnect = Off
+--FILE--
+<?php
+ include ("connect.inc");
+
+ $link = mysqli_init();
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(),
mysqli_connect_error());
+ }
+
+ $japanese_so = pack('H4', '835c');
+ $link->set_charset('sjis');
+ var_dump($link->real_escape_string($japanese_so) === $japanese_so);
+ mysqli_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+bool(true)
+done!
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c 2011-05-09 15:34:46 UTC (rev 310855)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c 2011-05-09 16:20:35 UTC (rev 310856)
@@ -327,10 +327,8 @@
/* {{{ sjis functions */
-#define valid_sjis_head(c) ((0x81 <= (c) && (c) <= 0x9F) && \
- (0xE0 <= (c) && (c) <= 0xFC))
-#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) && \
- (0x80 <= (c) && (c) <= 0x7C))
+#define valid_sjis_head(c) ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c)
&& (c) <= 0xFC))
+#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c)
&& (c) <= 0x7C))
static unsigned int check_mb_sjis(const char *start, const char *end)