[PATCH wayland] wayland-server: Properly handle EAGAIN from wl_connection_read()

Derek Foreman derekf at osg.samsung.com
Fri Apr 20 18:36:41 UTC 2018


On 2018-04-19 09:18 AM, Derek Foreman wrote:
> On 2018-04-19 09:01 AM, Derek Foreman wrote:
>> From: Dipen Somani <dipen.somani at samsung.com>
>>
>> commit 3cddb3c692acd3536a7cc8542a29f0cc3c0ac3d6 casted len to an
>> unsigned value to compare to sizeof results.  However,
>> wl_connection_read() can fail, setting errno to EAGAIN and returning
>> a value of -1.
>>
>> When cast to an unsigned type this leads to a loop condition of true
>> when it should be false.
>>
>> Signed-off-by: Dipen Somani <dipen.somani at samsung.com>
>> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> 
> I forgot to add:
> Reviewed-by: Derek Foreman <derekf at osg.samsung.com>

And have now landed it.

Thanks,
Derek

>> ---
>>  src/wayland-server.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/wayland-server.c b/src/wayland-server.c
>> index eb1e500..eab2ee4 100644
>> --- a/src/wayland-server.c
>> +++ b/src/wayland-server.c
>> @@ -353,7 +353,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
>>  		}
>>  	}
>>  
>> -	while ((size_t) len >= sizeof p) {
>> +	while (len >= 0 && (size_t) len >= sizeof p) {
>>  		wl_connection_copy(connection, p, sizeof p);
>>  		opcode = p[1] & 0xffff;
>>  		size = p[1] >> 16;
>>
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 



More information about the wayland-devel mailing list