[PHP-BUG] Bug #60779 [NEW]: Incorrect return value for getprotobyname
From: Operating system: Debian Squeeze PHP version: Irrelevant Package: *Network Functions Bug Type: Bug Bug description:Incorrect return value for getprotobyname Description: --- >From manual page: http://www.php.net/function.getprotobyname#refsect1-function.getprotobyname-returnvalues --- Return for unrecognized protocol is 0 instead of -1. PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26) Test script: --- Expected result: Invalid Protocol Actual result: -- Protocol #0 -- Edit bug report at https://bugs.php.net/bug.php?id=60779&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60779&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60779&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60779&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60779&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60779&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60779&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60779&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60779&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60779&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60779&r=support Expected behavior: https://bugs.php.net/fix.php?id=60779&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60779&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60779&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60779&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60779&r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=60779&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60779&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60779&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60779&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60779&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60779&r=mysqlcfg
Bug #60779 [Opn]: Incorrect return value for getprotobyname
Edit report at https://bugs.php.net/bug.php?id=60779&edit=1 ID: 60779 User updated by:wojtos at gmail dot com Reported by:wojtos at gmail dot com Summary:Incorrect return value for getprotobyname Status: Open Type: Bug Package:*Network Functions Operating System: Debian Squeeze PHP Version:Irrelevant Block user comment: N Private report: N New Comment: Thank You for your reply. Indeed I checked and it does return FALSE. The bug or rather misinformation lies in the documentation where it states "Returns the protocol number or -1 if the protocol is not found.". When in the test script I checked for === FALSE it worked as expected. Previous Comments: [2012-01-17 16:25:28] phpmpan at mpan dot pl Or you can't... Are you sure that you're receiving 0, not `FALSE`? If yes, than I'm NOT confirming this behaviour with 5.3.9, 5.3-dev, 5.4-dev or trunk-dev (on Arch64). In all four versions `getprotobyname` returns `FALSE`. Also returning 0 seems very strange. PHP just forwards the call to `getprotobyname` from netdb. In case of an error or if a protocol is not found, this function should return `NULL`. PHP checks if the call has returned `NULL` and, if it did, returns `FALSE`. Therefore if you're receiving 0, this would indicate a bug in the host environment, not in PHP itself. BEGIN CODE // ext/standard/basic_functions.c from SVN // ... ent = getprotobyname(name); if (ent == NULL) { RETURN_FALSE; } // ... - END CODE - [2012-01-17 15:46:49] phpmpan at mpan dot pl This is not a bug in `getprotobyname`. It's a bug in documentation for the function. `getprotobyname` returns `FALSE`, not 0 in case of an error. I will fill a report for that in a moment. You can close this one. -------- [2012-01-17 14:19:22] wojtos at gmail dot com Description: --- >From manual page: >http://www.php.net/function.getprotobyname#refsect1-function.getprotobyname-returnvalues --- Return for unrecognized protocol is 0 instead of -1. PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26) Test script: --- Expected result: Invalid Protocol Actual result: -- Protocol #0 -- Edit this bug report at https://bugs.php.net/bug.php?id=60779&edit=1
Bug #60779 [Dup]: Incorrect return value for getprotobyname
Edit report at https://bugs.php.net/bug.php?id=60779&edit=1 ID: 60779 User updated by:wojtos at gmail dot com Reported by:wojtos at gmail dot com Summary:Incorrect return value for getprotobyname Status: Duplicate Type: Bug Package:*Network Functions Operating System: Debian Squeeze PHP Version:Irrelevant Block user comment: N Private report: N New Comment: That is a duplicate of this and not the other way around! (id and time). Anyhow. Glad it's fixed. Previous Comments: [2012-01-20 02:22:30] larue...@php.net dup to #60781 [2012-01-18 08:21:40] wojtos at gmail dot com Thank You for your reply. Indeed I checked and it does return FALSE. The bug or rather misinformation lies in the documentation where it states "Returns the protocol number or -1 if the protocol is not found.". When in the test script I checked for === FALSE it worked as expected. [2012-01-17 16:25:28] phpmpan at mpan dot pl Or you can't... Are you sure that you're receiving 0, not `FALSE`? If yes, than I'm NOT confirming this behaviour with 5.3.9, 5.3-dev, 5.4-dev or trunk-dev (on Arch64). In all four versions `getprotobyname` returns `FALSE`. Also returning 0 seems very strange. PHP just forwards the call to `getprotobyname` from netdb. In case of an error or if a protocol is not found, this function should return `NULL`. PHP checks if the call has returned `NULL` and, if it did, returns `FALSE`. Therefore if you're receiving 0, this would indicate a bug in the host environment, not in PHP itself. BEGIN CODE // ext/standard/basic_functions.c from SVN // ... ent = getprotobyname(name); if (ent == NULL) { RETURN_FALSE; } // ... - END CODE - [2012-01-17 15:46:49] phpmpan at mpan dot pl This is not a bug in `getprotobyname`. It's a bug in documentation for the function. `getprotobyname` returns `FALSE`, not 0 in case of an error. I will fill a report for that in a moment. You can close this one. ---------------- [2012-01-17 14:19:22] wojtos at gmail dot com Description: --- >From manual page: >http://www.php.net/function.getprotobyname#refsect1-function.getprotobyname-returnvalues --- Return for unrecognized protocol is 0 instead of -1. PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26) Test script: --- Expected result: Invalid Protocol Actual result: -- Protocol #0 -- Edit this bug report at https://bugs.php.net/bug.php?id=60779&edit=1