NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

Files at this revision

API Documentation at this revision

Comitter:
Christopher Haster
Date:
Wed Apr 20 02:56:07 2016 -0500
Parent:
110:58aea4713a41
Child:
112:e0cbb3e43c20
Commit message:
Add workaround for bug in newlib scanf

https://bugs.launchpad.net/gcc-arm-embedded/+bug/1399224

Changed in this revision

SocketAddress.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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) {