php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37721 socket_recv() don't returns expected value when useing some flags
Submitted: 2006-06-06 22:13 UTC Modified: 2006-06-06 23:54 UTC
From: krzycho at wapp dot pl Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.4.2 OS: FreeBSD 5.4-R
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: krzycho at wapp dot pl
New email:
PHP Version: OS:

 

 [2006-06-06 22:13 UTC] krzycho at wapp dot pl
Description:
------------
some flags don't work correctly, cause returned value is not value returned by the recv() function...
some flags work correct(ex. MSG_PEEK), cause it don't modify value returned by the recv.

sockets.c (line 322): m = recv(bsd_socket, (void *) t, 1, flags);
sockets.c (line 341): return n;
should be when we use some flags: return m;

Reproduce code:
---------------
define("MSG_OOB",       1); 
define("MSG_PEEK",      2); 
define("MSG_DONTROUTE", 4); 
define("MSG_EOR",       8); 
define("MSG_TRUNC",     16);
define("MSG_CTRUNC",    32);
define("MSG_WAITALL",   64);
$flag=socket_recv($read, $data, 1024, MSG_TRUNC);
echo $flag;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-06 22:20 UTC] tony2001@php.net
Care to add expected and actual results?

 [2006-06-06 22:43 UTC] krzycho at wapp dot pl
ex:
when packet was send by:
socket_send ( resource socket, string buf, 1500, int flags )
real packet size will be 1500, and when we receive data return value should be that 1500 insend of that we currentlty read 1024... and we cound know that when we read again we got same packet.

linux man 2 recv:
MSG_TRUNC
Return the real length of the packet, even when  it  was  longer
than the passed buffer. Only valid for packet sockets.

i think it's enough example...
 [2006-06-06 22:55 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

We need BOTH expected *AND* actual results.

 [2006-06-06 23:43 UTC] krzycho at wapp dot pl
i searched again... and found that it rather depend on os not php... so it's os case(on linux should work, on bsd should work diffrent). php is ok ;)

sorry for problem, my mistake
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 18 08:03:18 2022 UTC