[OpenSER-Devel] null socket crash

Juha Heinanen jh at tutpro.com
Fri Oct 12 08:19:25 CEST 2007


this morning i noticed a crash in lcr module.  i had added a permanent
usrloc contact using ul_add mi function.  as result, i got into location
table an entry where socket field had NULL value.

one of things that lcr load_contacts function does is encoding of branch
info into a string that contains among other things socket value.  it
does socket to string conversion by calling socket_info.h function
socket2str like this:

    if (!socket2str(con->sock, at, &len)) {
	LM_ERR("Failed to convert socket to str\n");
	return 0;
    }

now if con->sock is null (0), the above socket2str call crashes
openser.

i could, of course, add a con->sock null test in lcr module before
calling socket2str, but i feel that a more proper place for the test
would be in socket2str function, because socket can be null and the
function should thus be able to handle also such sockets.

any opinions on this?

-- juha



More information about the Devel mailing list