dns_submit_srv() crashes if 'service' is string but 'protocol' is NULL
Michael Tokarev
mjt at tls.msk.ru
Tue Feb 8 10:51:46 MSK 2011
08.02.2011 03:14, Iñaki Baz Castillo wrote:
> Hi, dns_submit_srv() allows setting both service and protocol or no
> one of them. However if 'service' is a set but 'protocol' is not, then
> the following function crashes:
>
> build_srv_dn(dnsc_t *dn, const char *name, const char *srv, const char *proto)
> {
> unsigned p = 0, l;
> int isabs;
> if (srv) {
> l = add_sname(dn + p, srv);
> if (!l)
> return -1;
> p += l;
> l = add_sname(dn + p, proto);
> if (!l)
> return -1;
> p += l;
> }
>
> Maybe the function should check it?
Yes it should. This is one of very few functions in the library
which were contributed by others, and apparently I didn't check
it as carefully as my own code. The bug is obvious, thank you
for spotting it!
/mjt
More information about the udns
mailing list