Skip to content

Commit 6379d7c

Browse files
committed
net: dns: fix the sizeof the inet_ntop buffer with a sizeof macro
From the manpage for inet_ntop This function converts the network address structure src in the af address family into a character string. The resulting string is copied to the buffer pointed to by dst, which must be a non-null pointer. The caller specifies the number of bytes available in this buffer in the argument size. In an unintended misconfiguration the resolve max string ended up being 20 and tracking thru some wierd code issues determined some stack corruption which came back to the shell command. So, just fix the size argument to be the sizeof which then led to the next problem that the size is being ignored by inet_ntop. Signed-off-by: Charles Hardin <[email protected]>
1 parent 727c15a commit 6379d7c

File tree

1 file changed

+2
-2
lines changed
  • subsys/net/lib/shell

1 file changed

+2
-2
lines changed

subsys/net/lib/shell/dns.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ static void dns_result_cb(enum dns_resolve_status status,
3838
case AF_INET:
3939
net_addr_ntop(AF_INET,
4040
&net_sin(&info->ai_addr)->sin_addr,
41-
str, NET_IPV4_ADDR_LEN);
41+
str, sizeof(str));
4242
break;
4343

4444
case AF_INET6:
4545
net_addr_ntop(AF_INET6,
4646
&net_sin6(&info->ai_addr)->sin6_addr,
47-
str, NET_IPV6_ADDR_LEN);
47+
str, sizeof(str));
4848
break;
4949

5050
case AF_LOCAL:

0 commit comments

Comments
 (0)