From bdb18d9f48831cd31d42d3f0d8915c5aa5fe0f8e Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 18 Oct 2014 20:42:54 +0200 Subject: [PATCH] Fix execution of immediately following commands --- phpdbg_cmd.c | 8 ++++---- phpdbg_utils.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index ad49c62b25..d42ad36495 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -829,12 +829,12 @@ readline: #endif { char buf[PHPDBG_MAX_CMD]; - int bytes = 0, len = PHPDBG_G(input_buflen); + int bytes = PHPDBG_G(input_buflen), len = 0; if (PHPDBG_G(input_buflen)) { - memcpy(buf, PHPDBG_G(input_buffer), len); + memcpy(buf, PHPDBG_G(input_buffer), bytes); } - while ((bytes = read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len)) > 0 || (errno == EINTR && bytes < 0)) { + do { int i; if (bytes <= 0) { continue; @@ -862,7 +862,7 @@ readline: } } len += bytes; - } + } while ((bytes = read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len)) > 0 || (errno == EINTR && bytes < 0)); if (bytes <= 0) { goto disconnect; diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 5f94d21648..ca36f10874 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -1103,7 +1103,7 @@ static void phpdbg_encode_ctrl_chars(char **buf, int *buflen) { len += 4; *tmpptr++ = '&'; *tmpptr++ = '#'; - if ((unsigned int) ((*buf)[i]) > 10) { + if ((unsigned int) ((*buf)[i]) > 9) { *tmpptr++ = ((*buf)[i] / 10) + '0'; } else { --len; -- 2.40.0