Fix stkovf in mg_resolve_async_opt

PUBLISHED_FROM=8e37c51c6b0bf7d0782f3a997360827471b95d2e
This commit is contained in:
Alexander Alashkin 2016-11-25 08:04:38 +00:00 committed by Cesanta Bot
parent 55963d0c9a
commit 9125830de6

View File

@ -10414,9 +10414,9 @@ static int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
} else {
/* Try to figure out what nameserver to use */
for (ret = -1; fgets(line, sizeof(line), fp) != NULL;) {
char buf[256];
if (sscanf(line, "nameserver %255[^\n\t #]s", buf) == 1) {
snprintf(name, name_len, "udp://%s:53", buf);
unsigned int a, b, c, d;
if (sscanf(line, "nameserver %u.%u.%u.%u", &a, &b, &c, &d) == 4) {
snprintf(name, name_len, "udp://%u.%u.%u.%u:53", a, b, c, d);
ret = 0;
break;
}