Skip to content

Commit bf83cb2

Browse files
committed
nsapi - Fixed leftover bytes from suffix during ipv6 parsing
Thanks to @EduardPon for hunting this down
1 parent 382cb9f commit bf83cb2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

features/netsocket/SocketAddress.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ static void ipv6_from_address(uint8_t *bytes, const char *addr)
107107
{
108108
// Start with zeroed address
109109
uint16_t shorts[NSAPI_IPv6_BYTES/2];
110-
memset(shorts, 0, sizeof shorts);
111-
112110
int suffix = 0;
113111

114112
// Find double colons and scan suffix
@@ -122,6 +120,8 @@ static void ipv6_from_address(uint8_t *bytes, const char *addr)
122120
// Move suffix to end
123121
memmove(&shorts[NSAPI_IPv6_BYTES/2-suffix], &shorts[0],
124122
suffix*sizeof(uint16_t));
123+
memset(&shorts[0], 0,
124+
(NSAPI_IPv6_BYTES/2-suffix)*sizeof(uint16_t));
125125

126126
// Scan prefix
127127
ipv6_scan_chunk(shorts, &addr[0]);

0 commit comments

Comments
 (0)