php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63472 Not possibe to set SO_BINDTODEVICE with socket_set_option
Submitted: 2012-11-09 15:13 UTC Modified: 2013-06-23 22:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: zobo at scene-si dot org Assigned: stas (profile)
Status: Closed Package: Sockets related
PHP Version: master-Git-2012-11-09 (Git) OS: Linux
Private report: No CVE-ID: None
 [2012-11-09 15:13 UTC] zobo at scene-si dot org
Description:
------------
In network/socket programming in Linux there are situations when one needs to 
bind the socket to a specific interface. This is especially important when 
dealaing with broadcasts. Linux has SO_BINDTODEVICE to do this.
But currently it is impossible to use this option with PHP as any unknown 
options value will get translated to long and only then passed to setsockopt.

There are two ways to address this issue.

Change the default handler so, that if the argument is string, this is actually 
passed to setsockopt. This not only solves this issue, but also opens 
impossibles for future options with funky format where pack() may be abused to 
get them working without changes to the extension code.

But as this might break BC, there are two other approaches:
1. Just add a case statement specifically for SO_BINDTODEVICE
2. Add some sort of flag to the function parameters (either a bit in the options 
argument, or something else) that requests this special "raw" processing of the 
argument value.

It would make sense to have the socket_get_option counterpart also implemented. 
Not provided in the patch.



Patches

sockets_SO_BINDTODEVICE.diff (last revision 2012-11-09 15:14 UTC by zobo at scene-si dot org)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-23 22:31 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2013-06-23 22:31 UTC] stas@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2013-06-23 22:31 UTC] stas@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

merged as a0b4348abc09e00170a334c6f67ef399e8b36a1e
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC