nsapi - Fixed unaligned writes from <word-sized scanf calls

pull/2953/head
Christopher Haster 2016-10-19 16:49:35 -05:00
parent 281a0e2fe1
commit cce82b13ac
1 changed files with 8 additions and 2 deletions

View File

@ -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;