[Serdev] Bug in serunix

Martin Rusnak mafo at cyberspace.sk
Tue Jun 28 20:38:58 UTC 2005


>>Hi all,
>>
>>I encountered a bug in the serunix utility:
>>
>>file: serunix.c, line: 98
>>
>>The function recvfrom is called with parameter from_len. This causes the
>>"Invalid argument" error returned from the function.
> 
>   
>   The last parameter is a pointer to variable which will be filled with
>   the length of the source address of the received message, so I think
>   this is correct.
> 

That's true, it will be filled, but it also needs to be initialized with
the size of "struct sockaddr" before call of recvfrom. The serunix command
from the CVS always failed with the above mentioned error message. Then
after adding "from_len = sizeof(from)" before the recvfrom function call
it works correctly.

In unixsock_server.c it is implemented correctly:

line 489:
                 reply_addr_len = sizeof(reply_addr);
                 ret = recvfrom(rx_sock, buf, UNIXSOCK_BUF_SIZE, 0,
                                (struct sockaddr*)&reply_addr, &reply_addr_len);

Martin




More information about the Serdev mailing list