ap

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
111:df01ca3e89b3
Parent:
105:2fd212f8da61
Child:
120:6eb542426f15
--- a/SocketAddress.cpp	Tue Apr 19 20:09:46 2016 -0500
+++ b/SocketAddress.cpp	Wed Apr 20 02:56:07 2016 -0500
@@ -56,7 +56,23 @@
 
 static void ipv4_from_address(uint8_t *bytes, const char *addr)
 {
-    sscanf(addr, "%hhu.%hhu.%hhu.%hhu", &bytes[0], &bytes[1], &bytes[2], &bytes[3]);
+    int count = 0;
+    int i = 0;
+
+    for (; count < NSAPI_IPv4_BYTES; count++) {
+        int scanned = sscanf(&addr[i], "%hhu", &bytes[count]);
+        if (scanned < 1) {
+            return;
+        }
+
+        for (; addr[i] != '.'; i++) {
+            if (!addr[i]) {
+                return;
+            }
+        }
+
+        i++;
+    }
 }
 
 static int ipv6_scan_chunk(uint16_t *shorts, const char *chunk) {