sipd is "a high performance, scalable SIP (Session Initiation Protocol) proxy and location server written in C". A denial of service vulnerability in the product allows remote attackers to cause the server to crash by sending it a specially crafted SIP request.
SecurITeam would like to thank STORM for finding this vulnerability.
The program incorrectly checks only the return value of gethostbyname_r, i.e. if there is an error 1 is returned by the function. This causes a vulnerability, due to the fact that it is possible to trigger a situation where the function returns "0" and the "hres" value is NULL (which is later used).
This instance can be created for example by it trying to resolve something like "A192.168.1.6" (non-existing hostname).
This situation can be expected to happen if you read between the lines of the man file (regarding gethostbyname_r): "int gethostbyname_r (const char *name,
struct hostent *ret, char *buf, size_t buflen,
struct hostent **result, int *h_errnop);
Glibc2 also has reentrant versions gethostbyname_r() and gethostbyname2_r(). These return 0 on success and nonzero on error. The result of the call is now stored in the struct with address ret. After the call, *result will be NULL on error or point to the result on success. Auxiliary data is stored in the buffer buf of length buflen. (If the buffer is too small, these functions will return ERANGE.) No global variable h_errno is modified, but the address of a variable in which to store error numbers is passed in h_errnop."
So only checking for "0" is not enough, as no error is returned (in our special case), while the pointer returned by **result is NULL.
In our code, gethostbyname_r(p->tp->host, &hent, hbuf, sizeof(hbuf), &hres, &h_errno), returns 0, and the hres is NULL, causing the next line bcopy(hres->h_addr_list, (char *)&addr, sizeof(addr)) to fail miserably.