php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9042 Patch for exec() - one character output doesn't work
Submitted: 2001-01-31 19:56 UTC Modified: 2001-04-28 09:23 UTC
From: tunacat at yahoo dot com Assigned:
Status: Closed Package: Program Execution
PHP Version: 4.0.4pl1 OS: solaris 2.6
Private report: No CVE-ID: None
 [2001-01-31 19:56 UTC] tunacat at yahoo dot com
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;

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-22 18:47 UTC] sniper@php.net
reclassify
 [2001-04-28 09:21 UTC] elixer@php.net
Thank you for your patch.  Its now fixed in CVS.  It will be in 4.0.6.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 17:01:27 2024 UTC