Skip to content

Commit d4ae5bd

Browse files
committed
Fix for bug 54674..typo in the check of SJIS
1 parent 410a781 commit d4ae5bd

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

ext/mysqli/tests/bug54674.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #54674 mysqlnd valid_sjis_(head|tail) is using invalid operator and range.
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
?>
8+
--INI--
9+
mysqli.max_links = 1
10+
mysqli.allow_persistent = Off
11+
mysqli.max_persistent = 0
12+
mysqli.reconnect = Off
13+
--FILE--
14+
<?php
15+
include ("connect.inc");
16+
17+
$link = mysqli_init();
18+
if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
19+
printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
20+
}
21+
22+
$japanese_so = pack('H4', '835c');
23+
$link->set_charset('sjis');
24+
var_dump($link->real_escape_string($japanese_so) === $japanese_so);
25+
mysqli_close($link);
26+
27+
print "done!";
28+
?>
29+
--EXPECTF--
30+
bool(true)
31+
done!

ext/mysqlnd/mysqlnd_charset.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,8 @@ static unsigned int mysqlnd_mbcharlen_gbk(unsigned int gbk)
327327

328328

329329
/* {{{ sjis functions */
330-
#define valid_sjis_head(c) ((0x81 <= (c) && (c) <= 0x9F) && \
331-
(0xE0 <= (c) && (c) <= 0xFC))
332-
#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) && \
333-
(0x80 <= (c) && (c) <= 0x7C))
330+
#define valid_sjis_head(c) ((0x81 <= (c) && (c) <= 0x9F) || (0xE0 <= (c) && (c) <= 0xFC))
331+
#define valid_sjis_tail(c) ((0x40 <= (c) && (c) <= 0x7E) || (0x80 <= (c) && (c) <= 0x7C))
334332

335333

336334
static unsigned int check_mb_sjis(const char *start, const char *end)

0 commit comments

Comments
 (0)