mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-05 17:28:02 +00:00
Apply modified patch from Daniel Elstner to fix bug #49124: mDNS should not use snprintf()
This commit is contained in:
parent
ee4cd45c98
commit
2facd2d64d
@ -504,9 +504,15 @@ mdns_build_reverse_v4_domain(struct mdns_domain *domain, const ip4_addr_t *addr)
|
||||
memset(domain, 0, sizeof(struct mdns_domain));
|
||||
ptr = (const u8_t *) addr;
|
||||
for (i = sizeof(ip4_addr_t) - 1; i >= 0; i--) {
|
||||
char buf[4];
|
||||
size_t len = snprintf(buf, sizeof(buf), "%d", ptr[i]);
|
||||
res = mdns_domain_add_label(domain, buf, (u8_t)len);
|
||||
char buf[3];
|
||||
size_t pos = sizeof(buf);
|
||||
u8_t val = ptr[i];
|
||||
do {
|
||||
pos--;
|
||||
buf[pos] = '0' + (val % 10);
|
||||
val /= 10;
|
||||
} while (val != 0); /* loop is correct because u8_t needs at most 3 chars */
|
||||
res = mdns_domain_add_label(domain, &buf[pos], (u8_t)(3 - pos));
|
||||
LWIP_ERROR("mdns_build_reverse_v4_domain: Failed to add label", (res == ERR_OK), return res);
|
||||
}
|
||||
res = mdns_domain_add_label(domain, REVERSE_PTR_V4_DOMAIN, (u8_t)(sizeof(REVERSE_PTR_V4_DOMAIN)-1));
|
||||
|
Loading…
Reference in New Issue
Block a user