com php-src: Fix off-by-one bug in text messages (msg/<phpdbg>): phpdbg_utils.c
| From: | Bob Weinand | Date: | Mon, 20 Oct 2014 19:52:47 +0000 |
| Subject: | com php-src: Fix off-by-one bug in text messages (msg/<phpdbg>): phpdbg_utils.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82527@lists.php.net to get a copy of this message | ||
Commit: dfdc19fb2a3a4e3ed7627e47678e63b02cb01278
Author: Bob Weinand <bobwei9@hotmail.com> Mon, 20 Oct 2014 21:52:47 +0200
Parents: 27629577b07efb18b7fbcdf4faeffef67d6cec64
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dfdc19fb2a3a4e3ed7627e47678e63b02cb01278
Log:
Fix off-by-one bug in text messages (msg/<phpdbg>)
Changed paths:
M phpdbg_utils.c
Diff:
diff --git a/phpdbg_utils.c b/phpdbg_utils.c
index e9fbdef..ecdb5fb 100644
--- a/phpdbg_utils.c
+++ b/phpdbg_utils.c
@@ -1094,7 +1094,7 @@ static int phpdbg_encode_xml(char **buf, char *msg, int msglen, int from, char
*
int i;
int tolen = to ? strlen(to) : 5;
char *tmp = *buf = emalloc(msglen * tolen);
- for (i = 0; ++i < msglen; msg++) {
+ for (i = 0; i++ < msglen; msg++) {
if (*msg == '&') {
memcpy(tmp, ZEND_STRL("&"));
tmp += sizeof("&") - 1;
@@ -1118,20 +1118,17 @@ static int phpdbg_encode_xml(char **buf, char *msg, int msglen, int from,
char *
static void phpdbg_encode_ctrl_chars(char **buf, int *buflen) {
char *tmp, *tmpptr;
- int len = *buflen;
+ int len;
int i;
tmp = tmpptr = emalloc(*buflen * 5);
for (i = 0; i < *buflen; i++) {
if ((*buf)[i] < 0x20) {
- len += 4;
*tmpptr++ = '&';
*tmpptr++ = '#';
if ((unsigned int) ((*buf)[i]) > 9) {
*tmpptr++ = ((*buf)[i] / 10) + '0';
- } else {
- --len;
}
*tmpptr++ = ((*buf)[i] % 10) + '0';
*tmpptr++ = ';';