PHP 4.0 Bug #9042: Patch for exec() - one character output doesn't work
| From: | tunacat at yahoo dot com | Date: | Thu, 01 Feb 2001 00:56:56 +0000 |
| Subject: | PHP 4.0 Bug #9042: Patch for exec() - one character output doesn't work | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-45496@lists.php.net to get a copy of this message | ||
From: tunacat@yahoo.com
Operating system: solaris 2.6
PHP version: 4.0.4pl1
PHP Bug Type: Unknown/Other Function
Bug description: Patch for exec() - one character output doesn't work
When I exec() a program, and the program produces a single character as output (no newline), the
output does not make it back to PHP.
Here is a patch to fix the problem:
*** exec.c.orig Wed Jan 31 16:06:57 2001
--- exec.c Wed Jan 31 16:16:38 2001
***************
*** 163,170 ****
/* strip trailing spaces */
l = strlen(buf);
t = l;
! while (l && isspace((int)buf[--l]));
! if (l < t) buf[l + 1] = '\0';
/* Return last line from the shell command */
if (PG(magic_quotes_runtime)) {
--- 163,172 ----
/* strip trailing spaces */
l = strlen(buf);
t = l;
! while (l && isspace((int)buf[l - 1])) {
! l--;
! }
! if (l < t) buf[l] = '\0';
/* Return last line from the shell command */
if (PG(magic_quotes_runtime)) {
***************
*** 173,179 ****
tmp = php_addslashes(buf, 0, &len, 0);
RETVAL_STRINGL(tmp,len,0);
} else {
! RETVAL_STRINGL(buf,l?l+1:0,1);
}
} else {
int b, i;
--- 175,181 ----
tmp = php_addslashes(buf, 0, &len, 0);
RETVAL_STRINGL(tmp,len,0);
} else {
! RETVAL_STRINGL(buf,l,1);
}
} else {
int b, i;
--
Edit Bug report at: http://bugs.php.net/?id=9042&edit=1