[php-src] Issue #14867: addslashes() fails to escape the NUL byte correctly.
| From: | Wiimm | Date: | Mon, 08 Jul 2024 07:08:26 +0000 |
| Subject: | [php-src] Issue #14867: addslashes() fails to escape the NUL byte correctly. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247249@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14867
Author: Wiimm
### Description
The following code: ``
echo addslashes("\00040");'``
Resulted in this output: ``\040`` (same as "!").
But I expected this output instead: ``\00040`` (NUL + "40")
The issue is, that the NUL byte is escaped to ``\0``. But if the NUL byte is followed
by valid octal digits, up of 2 of them will be interpreted as part of the escape.
**Solution:** Always escape the NUL byte to ``\000``.
### PHP Version
PHP 7.2.5 .. 8.3.7
### Operating System
OpenSUSE, Debian