|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72225 NULL is not correct escaped by mysqli.real-escape-string
Submitted: 2016-05-16 17:27 UTC Modified: 2016-05-16 17:55 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dc at ftb-esv dot de Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.5.35 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dc at ftb-esv dot de
New email:
PHP Version: OS:


 [2016-05-16 17:27 UTC] dc at ftb-esv dot de
From manual page:
real_escape_string escapes a NULL to "\0", but this is wrong!
It must be escaped to "\000" or conversions are wrong, if a digit follows.

Test script:
$a = "a\000" . "1b";
echo mysqli->real_escape_string($a);

a\01b => 'a' . '\01' . 'b'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-16 17:55 UTC]
-Status: Open +Status: Not a bug -Package: *General Issues +Package: MySQLi related
 [2016-05-16 17:55 UTC]
MySQL does not have octal escape sequences.

mysql> SELECT "a\01b";
| a    |
| a 1b |
1 row in set (0.00 sec)

mysql> SELECT HEX("a\01b");
| HEX("a\01b") |
| 61003162     |
1 row in set (0.07 sec)
 [2016-05-18 07:59 UTC] dc at ftb-esv dot de
With this new knowledge (mysql don't support octal escapes) I found the bug in a class of my company.

Thanks for response.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 21:03:39 2021 UTC