Bind bug in irserver's server.c

All LINUX related questions (Installation & usage)

Moderator: marcus

Bind bug in irserver's server.c

Postby irtrans0 » Mon 25. Jan 2010, 07:12

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.
irtrans0
 
Posts: 1
Joined: Mon 25. Jan 2010, 07:00

Re: Bind bug in irserver's server.c

Postby IRTrans » Mon 25. Jan 2010, 12:22

We will check that ...

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Bind bug in irserver's server.c

Postby IRTrans » Thu 18. Feb 2010, 15:48

Hi,
we have changed that - it will be included in the next release.

Thank you for point out that error.

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32


Return to LINUX

Who is online

Users browsing this forum: No registered users and 6 guests