[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in phpdbg8.3 (also 8.1 and 8.2) echo output - trimmed at NULL byte (?) #14553

Closed
smuuf opened this issue Jun 13, 2024 · 1 comment
Closed

Comments

@smuuf
Copy link
smuuf commented Jun 13, 2024

Description

The following code:

<?php

echo "hello\0world";

✅ Results in this output when executed with php8.3 (also php8.2 and php8.1 and php8.0):

helloworld

❌ But results in this output when executed with phpdbg8.3 (also phpdbg8.2 and phpdbg8.1):

hello

And I expected this output from phpdbg8.* instead:

helloworld

❔Interesting thing is that phpdbg8.0 output is correct:

helloworld

... so the change in behavior seems to be somewhere in between latest 8.0.* and 8.1.

Steps to reproduce with docker

php8.0 ✅

docker run -it php:8.0-cli bash -c 'php --version; echo; echo "<?php echo \"hello\" . chr(0) . \"world\";" > lol.php; echo -n "php .|"; php lol.php; echo -en "|.\nphpdbg .|"; phpdbg -qrrb lol.php; echo "|."'

PHP 8.0.30 (cli) (built: Nov 21 2023 16:10:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies

php .|helloworld|.
phpdbg .|helloworld|.

php8.1 ❌

docker run -it php:8.1-cli bash -c 'php --version; echo; echo "<?php echo \"hello\" . chr(0) . \"world\";" > lol.php; echo -n "php .|"; php lol.php; echo -en "|.\nphpdbg .|"; phpdbg -qrrb lol.php; echo "|."'

PHP 8.1.29 (cli) (built: Jun 13 2024 03:00:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.29, Copyright (c) Zend Technologies

php .|helloworld|.
phpdbg .|hello|.

php8.2 ❌

docker run -it php:8.2-cli bash -c 'php --version; echo; echo "<?php echo \"hello\" . chr(0) . \"world\";" > lol.php; echo -n "php .|"; php lol.php; echo -en "|.\nphpdbg .|"; phpdbg -qrrb lol.php; echo "|."'

PHP 8.2.20 (cli) (built: Jun 13 2024 02:30:07) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.20, Copyright (c) Zend Technologies

php .|helloworld|.
phpdbg .|hello|.

php8.3 ❌

docker run -it php:8.3-cli bash -c 'php --version; echo; echo "<?php echo \"hello\" . chr(0) . \"world\";" > lol.php; echo -n "php .|"; php lol.php; echo -en "|.\nphpdbg .|"; phpdbg -qrrb lol.php; echo "|."'

PHP 8.3.8 (cli) (built: Jun 13 2024 01:58:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.8, Copyright (c) Zend Technologies

php .|helloworld|.
phpdbg .|hello|.

PHP Version

PHP 8,1-8.3

Operating System

WSL1, WSL2 and also bare Ubuntu

@nielsdos
Copy link
Member
nielsdos commented Jul 4, 2024

Regressed in 6318040

nielsdos added a commit to nielsdos/php-src that referenced this issue Jul 4, 2024
…immed at NULL byte (?)

This broke in 6318040 when phpdbg
stopped using its custom printing routines. By relying on standard
printing routines, the embedded NUL bytes are causing the strings to be
cut off, even when using %.*s. Solve this by going straight to the
output routine, which is what the printf routine would've done anyway.
nielsdos added a commit that referenced this issue Jul 4, 2024
* PHP-8.2:
  Fix GH-14553: Bug in phpdbg8.3 (also 8.1 and 8.2) echo output - trimmed at NULL byte (?)
nielsdos added a commit that referenced this issue Jul 4, 2024
* PHP-8.3:
  Fix GH-14553: Bug in phpdbg8.3 (also 8.1 and 8.2) echo output - trimmed at NULL byte (?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants