Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array) /* {{{ */

static inline size_t php_sapi_phpdbg_ub_write(const char *message, size_t length) /* {{{ */
{
return phpdbg_script(P_STDOUT, "%.*s", (int) length, message);
return phpdbg_process_print(PHPDBG_G(io)[PHPDBG_STDOUT].fd, P_STDOUT, message, (int) length);
} /* }}} */

/* beginning of struct, see main/streams/plain_wrapper.c line 111 */
Expand Down
2 changes: 1 addition & 1 deletion sapi/phpdbg/phpdbg_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PHPDBG_API int _phpdbg_asprintf(char **buf, const char *format, ...) {
return ret;
}

static int phpdbg_process_print(int fd, int type, const char *msg, int msglen) {
int phpdbg_process_print(int fd, int type, const char *msg, int msglen) {
char *msgout = NULL;
int msgoutlen = FAILURE;

Expand Down
2 changes: 2 additions & 0 deletions sapi/phpdbg/phpdbg_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ PHPDBG_API void phpdbg_free_err_buf(void);
PHPDBG_API void phpdbg_activate_err_buf(bool active);
PHPDBG_API int phpdbg_output_err_buf(const char *strfmt, ...);

int phpdbg_process_print(int fd, int type, const char *msg, int msglen);


/* {{{ For separation */
#define SEPARATE "------------------------------------------------" /* }}} */
Expand Down
Binary file modified sapi/phpdbg/tests/gh10715.phpt
Binary file not shown.
14 changes: 14 additions & 0 deletions sapi/phpdbg/tests/gh14553.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
GH-14553 (Bug in phpdbg8.3 (also 8.1 and 8.2) echo output - trimmed at NULL byte (?))
--PHPDBG--
r
q
--FILE--
<?php
echo "hello\0world";
?>
--EXPECTF--
[Successful compilation of %s]
prompt> hello%0world
[Script ended normally]
prompt>
Loading