mirror of git://git.musl-libc.org/musl
remove an extra layer of buffer copying in getnameinfo reverse dns
the outer getnameinfo function already has a properly-sized temporary
buffer for storing the reverse dns (ptr) result. there is no reason
for the callback to use a secondary buffer and copy it on success, and
doing so potentially expanded the impact of the dn_expand bug that was
fixed in commit 49d2c8c6bc
.
this change reduces the code size by a small amount, and also reduces
the run-time stack space requirements by about 256 bytes.
This commit is contained in:
parent
6e2bb7acf4
commit
80e6485455
|
@ -113,11 +113,10 @@ static void reverse_services(char *buf, int port, int dgram)
|
||||||
|
|
||||||
static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet)
|
static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet)
|
||||||
{
|
{
|
||||||
char tmp[256];
|
|
||||||
if (rr != RR_PTR) return 0;
|
if (rr != RR_PTR) return 0;
|
||||||
if (__dn_expand(packet, (const unsigned char *)packet + 512,
|
if (__dn_expand(packet, (const unsigned char *)packet + 512,
|
||||||
data, tmp, sizeof tmp) > 0)
|
data, c, 256) <= 0)
|
||||||
strcpy(c, tmp);
|
*(char *)c = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue