nsapi - Fixed leftover bytes from suffix during ipv6 parsing

Thanks to @EduardPon for hunting this down
pull/3144/head
Christopher Haster 2016-10-06 10:53:48 -05:00 committed by Anna Bridge
parent 350a5a4b31
commit 8dcbf63bb6
1 changed files with 2 additions and 2 deletions

View File

@ -107,8 +107,6 @@ static void ipv6_from_address(uint8_t *bytes, const char *addr)
{ {
// Start with zeroed address // Start with zeroed address
uint16_t shorts[NSAPI_IPv6_BYTES/2]; uint16_t shorts[NSAPI_IPv6_BYTES/2];
memset(shorts, 0, sizeof shorts);
int suffix = 0; int suffix = 0;
// Find double colons and scan suffix // Find double colons and scan suffix
@ -122,6 +120,8 @@ static void ipv6_from_address(uint8_t *bytes, const char *addr)
// Move suffix to end // Move suffix to end
memmove(&shorts[NSAPI_IPv6_BYTES/2-suffix], &shorts[0], memmove(&shorts[NSAPI_IPv6_BYTES/2-suffix], &shorts[0],
suffix*sizeof(uint16_t)); suffix*sizeof(uint16_t));
memset(&shorts[0], 0,
(NSAPI_IPv6_BYTES/2-suffix)*sizeof(uint16_t));
// Scan prefix // Scan prefix
ipv6_scan_chunk(shorts, &addr[0]); ipv6_scan_chunk(shorts, &addr[0]);