Project

General

Profile

Actions

Bug #2496

closed

The use of php exec() and php system() with pipe '|' will fail if the first output of a os command is long enough.

Added by robert zelaya almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Operating System
Target version:
Start date:
06/14/2012
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.1
Affected Architecture:
All

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

Actions

Also available in: Atom PDF