Page 1 of 1

Bind bug in irserver's server.c

PostPosted: Mon 25. Jan 2010, 07:12
by irtrans0
There is a nasty bug in server.c for irserver where bind to a local socket is performed.

The line:

> if (bind (local_socket, (struct sockaddr *)&serv_addr_un, sizeof(serv_addr)) == -1

should be:

> if (bind (local_socket, (struct sockaddr *)&serv_addr_un, sizeof(serv_addr_un)) == -1

This because the serv_addr is actually of type sockaddr_in and is only used later in the code for binding to a tcp socket. The actual UNIX socket being used has an address of type sockaddr_un (albeit cast to struct sockaddr).

This bug becomes very apparent if you change the constant LIRCD definition to "/var/run/lirc/lircd" which is what default lirc clients expect these days (because on modern linux systems /dev is not really the appropriate place for applications to create filesystem sockets any more). If you do use "/var/run/lirc/lircd" then you will get a "Could not open IP socket" error. This is because the sizeof(serv_addr) is 16 and after subtracting the 4 bytes for sa_family this only leaves 12 bytes for the path. The proper sizeof(serv_addr_un) is 100 bytes.

Re: Bind bug in irserver's server.c

PostPosted: Mon 25. Jan 2010, 12:22
by IRTrans
We will check that ...

IRTrans

Re: Bind bug in irserver's server.c

PostPosted: Thu 18. Feb 2010, 15:48
by IRTrans
Hi,
we have changed that - it will be included in the next release.

Thank you for point out that error.

IRTrans