#32324 [NEW]: socket_recvfrom stops reading at null char
| From: | admin at freeworldonline dot com | Date: | Tue, 15 Mar 2005 19:19:08 +0000 |
| Subject: | #32324 [NEW]: socket_recvfrom stops reading at null char | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-75380@lists.php.net to get a copy of this message | ||
From: admin at freeworldonline dot com
Operating system: Linux stripples.devel.redhat.com
PHP version: 4.3.10
PHP Bug Type: Unknown/Other Function
Bug description: socket_recvfrom stops reading at null char
Description:
------------
I am trying to recieve data via a UDP socket using the socket_recvfrom
function. It works fine unless there is a null char anywhere in the
packet.
If there is the buffer returned only contains data up to that point,
although the value returned by the function shows there is actually more
data.
Reproduce code:
---------------
if (!$sock=socket_create(AF_INET,SOCK_DGRAM,SOL_UDP)) {
echo "<b>Error:</b> Failed to create socket,
".socket_strerror(socket_last_error($sock))."<br>\n";
} elseif (!socket_bind($sock,"0.0.0.0",41330)) {
echo "<b>Error:</b> Failed to bind socket,
".socket_strerror(socket_last_error($sock))."<br>\n";
socket_close($sock);
} else {
echo "<b>Ready, please send a message to port 41330 using
UDP</b><br><br>\n";
$size=socket_recvfrom($sock,$buf,65535,0,$clientIP,$clientPort);
if ($buf===FALSE) {
echo "<b>Error:</b> Returned false,
".socket_strerror(socket_last_error($sock))."<br>\n";
} else {
echo "Message from ".$clientIP.":".$clientPort."
(".strlen($buf)."/".$size." bytes)...<br>\n";
}
socket_close($sock);
}
Expected result:
----------------
All data to be placed into the buffer regardless of any null characters in
the packet.
Actual result:
--------------
If you send a datagram to port 41330 while this is running with a null
character mid way into the packet, any data from there onwards will not be
placed into $buf.
--
Edit bug report at http://bugs.php.net/?id=32324&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32324&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32324&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32324&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32324&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32324&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32324&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32324&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32324&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32324&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32324&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32324&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32324&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32324&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32324&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32324&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32324&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32324&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32324&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32324&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32324&r=mysqlcfg