From 198f5b95140b52b5a3aad343e62fc0c9b03b9ae7 Mon Sep 17 00:00:00 2001 From: Ahab Date: Sun, 3 Oct 2021 01:09:59 +0800 Subject: fix(ext/net): should not panic when listening to unix abstract address (#12300) --- cli/tests/unit/net_test.ts | 15 +++++++++++++++ ext/net/ops.rs | 6 +----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cli/tests/unit/net_test.ts b/cli/tests/unit/net_test.ts index 180f8d88e..a1585ce6b 100644 --- a/cli/tests/unit/net_test.ts +++ b/cli/tests/unit/net_test.ts @@ -625,3 +625,18 @@ unitTest( listener.close(); }, ); + +unitTest( + { + ignore: Deno.build.os !== "linux", + permissions: { read: true, write: true }, + }, + function netUnixAbstractPathShouldNotPanic() { + const listener = Deno.listen({ + path: "\0aaa", + transport: "unix", + }); + assert("not panic"); + listener.close(); + }, +); diff --git a/ext/net/ops.rs b/ext/net/ops.rs index 158f25515..52e513f71 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -518,11 +518,7 @@ where } else { net_unix::listen_unix_packet(state, address_path)? }; - debug!( - "New listener {} {}", - rid, - local_addr.as_pathname().unwrap().display(), - ); + debug!("New listener {} {:?}", rid, local_addr); let unix_addr = net_unix::UnixAddr { path: local_addr.as_pathname().and_then(net_unix::pathstring), }; -- cgit v1.2.3