Bug #2496
closedThe use of php exec() and php system() with pipe '|' will fail if the first output of a os command is long enough.
0%
Description
System:
uname -a
FreeBSD pfSense.localdomain 8.3-RELEASE-p2 FreeBSD 8.3-RELEASE-p2 #0: Mon Jun 11 02:55:34 EDT 2012
root@FreeBSD_8.3_pfSense_2.1.snaps.pfsense.org:/usr/obj./usr/pfSensesrc/src/sys/pfSense_SMP.8 amd64
Problem:
The use of php exec() and php system() with pipe '|' will fail if the first output of a os command is long enough.
Moreover, if the the output of the first os cmd grows over time (memory) you might see this on edge cases.
Example:
/* checks to see if barnyard2 is running yes/no */
function Running_Ck_b($snort_uuid, $if_real, $id) {
$option1 = shell_exec("pgrep -f 'barnyard.*{$snort_uuid}_{$if_real}'"); // pass
$option2 = exec("/bin/ps -aux | /usr/bin/grep -v grep | /usr/bin/grep -E 'barnyard2.*snort_49127_em0' | /usr/bin/awk '{print \$1;}'"); // fail
$option3 = exec("/bin/ps -aux | /usr/bin/grep 'lighttpd'"); // fail
$option4 = passthru("/bin/ps -aux"); // pass
return $option4;
}
Notes:
All code using FreeBSD '|' cmd should be reviewed. Thankfully there is not much code to fix.
Robert
Updated by Chris Buechler over 12 years ago
- Status changed from New to Feedback
Not sure what you're seeing, but none of us can replicate that with the exact same thing you're doing substituting different processes for barnyard. If this were true we'd have other things broken that work fine. Seriously doubt the problem described here exists, likely it's somewhere else in your code.
Updated by robert zelaya over 12 years ago
Hi Chris
I don't know why you guys can't reproduce this.
The code is being watched live through Xdebug v2.1.3 and I can not see exec returning anything.
Also, tested this issue with a empty file with only the above function.
My setup:
VMware workstation:
x64
512 mb
Robert
Updated by Chris Buechler about 12 years ago
- Status changed from Feedback to Closed
the issue as described doesn't really exist.