Bug #79691 [NEW]: Lack of error checking in `posix_kill`

From: Date: Thu, 11 Jun 2020 22:48:44 +0000
Subject: Bug #79691 [NEW]: Lack of error checking in `posix_kill`
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227426@lists.php.net to get a copy of this message
From: srivas41 at purdue dot edu Operating system: Ubuntu 16.04 PHP version: 7.4.7 Package: Reproducible crash Bug Type: Bug Bug description:Lack of error checking in posix_kill Description: ------------ Posix_kill lacks error checking for undefined variables passed and instead gets typecasted to 0 somehow owing to the internal implementation. As specified in the kill(2) manpage, `If pid equals 0, then sig is sent to every process in the process group of the calling process. Therefore, posix_kill` will incorrectly send the signal to all processes in the process group which includes the interpreter itself. This behavior can be detrimental if a developer mistakingly passes an undefined variable to posix_kill. This behavior is reproducible with the script specified below. The script sends SIGHUP to the interpreter and exits prematurely due to lack of error checking for undefined variables in posix_kill. Therefore, before printing the last echo statement, posix_kill passes SIGHUP to the interpreter itself exiting prematurely. Test script: --------------- <?php echo "Testing Posix kill\n"; $signal_number=1; //SIGHUP=1 posix_kill($DUMMY, $signal_number); // $DUMMY is undefined echo "Posix kill can error check for undefined variables!"; ?> Expected result: ---------------- Ideally, PHP interpreter should raise an error for an undefined variable for the above test script instead of just weakly typing the undefined variable to 0. Actual result: -------------- The message displayed would be something like: ``` Testing Posix kill [2] <PHP Interpreter PID> hangup ./sapi/cli/php -f test.php ``` -- Edit bug report at https://bugs.php.net/bug.php?id=79691&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79691&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79691&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79691&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79691&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79691&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79691&r=support Expected behavior: https://bugs.php.net/fix.php?id=79691&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79691&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79691&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79691&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79691&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79691&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79691&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79691&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79691&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79691&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79691&r=mysqlcfg

« previous php.bugs (#227426) next »