[PATCH 1/7] ws2_32: Return WSAEFAULT from setsockopt() for IP_MULTICAST_LOOP with zero optlen.

Paul Gofman pgofman at codeweavers.com
Tue Mar 8 11:47:46 CST 2022


On 3/8/22 19:59, Zebediah Figura wrote:
> On 3/8/22 03:22, Paul Gofman wrote:
>> Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
>> ---
>>   dlls/ws2_32/socket.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
>> index dacb41a0403..816ca828b90 100644
>> --- a/dlls/ws2_32/socket.c
>> +++ b/dlls/ws2_32/socket.c
>> @@ -2981,6 +2981,11 @@ int WINAPI setsockopt( SOCKET s, int level, 
>> int optname, const char *optval, int
>>               return server_setsockopt( s, 
>> IOCTL_AFD_WINE_SET_IP_MULTICAST_IF, optval, optlen );
>>             case IP_MULTICAST_LOOP:
>> +            if (!optlen)
>> +            {
>> +                SetLastError( WSAEFAULT );
>> +                return -1;
>> +            }
>>               return server_setsockopt( s, 
>> IOCTL_AFD_WINE_SET_IP_MULTICAST_LOOP, optval, optlen );
>>             case IP_MULTICAST_TTL:
>
> Maybe I'm missing something, but given the tests in 4/7, couldn't this 
> be simplified by handling it outside of the inner switch, like in 
> 9744055cf4?
>
Possibly, but in the end of my patchset half of the options have 'optlen 
< sizeof(DWORD)' condition. Also, my patchset doesn't add tests for 
"non-DWORD" options "IP_ADD_MEMBERSHIP" and so I don't know if that 
condition applies there. So it isn't apparent for me if generalizing it 
simplifies it, it looks like at very least I'd need to add more tests 
for that not directly related to the initial patchset scope.




More information about the wine-devel mailing list