Skip to content

Commit 688d97e

Browse files
committed
Add NULL check in ns_lookup_list_search for DNS resolution
When no DNS allowlist is configured via --allow-resolve, wasi_ctx->ns_lookup_list is NULL. This NULL pointer gets passed to ns_lookup_list_search which dereferences it unconditionally at the while (*list) loop, causing a crash. A guest WASM module can trigger this by calling sock_addr_resolve.
1 parent c46b10d commit 688d97e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ ns_lookup_list_search(char **list, const char *host)
7474
{
7575
size_t host_len = strlen(host), suffix_len;
7676

77+
if (!list)
78+
return false;
79+
7780
while (*list) {
7881
if (*list[0] == '*') {
7982
suffix_len = strlen(*list) - 1;

0 commit comments

Comments
 (0)