Skip to content

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

Closed
@smuuf

Description

@smuuf

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions