From 9125830de6ab9a8f7a492324b11b1aa18aeaa1ed Mon Sep 17 00:00:00 2001
From: Alexander Alashkin <alexander.alashkin@cesanta.com>
Date: Fri, 25 Nov 2016 08:04:38 +0000
Subject: [PATCH] Fix stkovf in mg_resolve_async_opt

PUBLISHED_FROM=8e37c51c6b0bf7d0782f3a997360827471b95d2e
---
 mongoose.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index 60ecba4bf..d94e14d2b 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -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;
       }
-- 
GitLab