diff --git a/features/netsocket/SocketAddress.cpp b/features/netsocket/SocketAddress.cpp index 62165423fc..2a8a8d7a44 100644 --- a/features/netsocket/SocketAddress.cpp +++ b/features/netsocket/SocketAddress.cpp @@ -66,11 +66,14 @@ static void ipv4_from_address(uint8_t *bytes, const char *addr) int i = 0; for (; count < NSAPI_IPv4_BYTES; count++) { - int scanned = sscanf(&addr[i], "%hhu", &bytes[count]); + unsigned char b; + int scanned = sscanf(&addr[i], "%hhu", &b); if (scanned < 1) { return; } + bytes[count] = b; + for (; addr[i] != '.'; i++) { if (!addr[i]) { return; @@ -86,11 +89,14 @@ static int ipv6_scan_chunk(uint16_t *shorts, const char *chunk) { int i = 0; for (; count < NSAPI_IPv6_BYTES/2; count++) { - int scanned = sscanf(&chunk[i], "%hx", &shorts[count]); + unsigned short s; + int scanned = sscanf(&chunk[i], "%hx", &s); if (scanned < 1) { return count; } + shorts[count] = s; + for (; chunk[i] != ':'; i++) { if (!chunk[i]) { return count+1;