diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2015-11-11 11:39:10 +0100 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2015-11-11 11:39:10 +0100 |
commit | ed0a785f024ff6d924eea9f52de22e4f0e249787 (patch) | |
tree | e0b5d2dbc7658e0ec768e04465a84ff42e6e9ec4 | |
parent | 7cb9a80744aa47c1eb7bf4b1a32cfaf320fc8ef8 (diff) | |
download | ocaml-ed0a785f024ff6d924eea9f52de22e4f0e249787.tar.gz |
PR#7039: Unix.getsockname returns garbage for unnamed PF_UNIX sockets.
Fix implemented: return ADDR_UNIX "" in this case (the file name is the empty string).
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | otherlibs/unix/socketaddr.c | 9 |
2 files changed, 10 insertions, 1 deletions
@@ -261,6 +261,8 @@ Bug fixes: (report and fix by Patrick Star) - PR#7036: Module alias is not taken into account when checking module type compatibility (in a class type) (Jacques Garrigue) +- PR#7039: Unix.getsockname returns garbage for unnamed PF_UNIX sockets + (Xavier Leroy) - GPR#205: Clear caml_backtrace_last_exn before registering as root (report and fix by Frederic Bour) - GPR#220: minor -dsource error on recursive modules diff --git a/otherlibs/unix/socketaddr.c b/otherlibs/unix/socketaddr.c index 2eca8fc5b8..7137848e7a 100644 --- a/otherlibs/unix/socketaddr.c +++ b/otherlibs/unix/socketaddr.c @@ -105,7 +105,14 @@ value alloc_sockaddr(union sock_addr_union * adr /*in*/, switch(adr->s_gen.sa_family) { #ifndef _WIN32 case AF_UNIX: - { value n = copy_string(adr->s_unix.sun_path); + { char * path; + value n; + /* PR#7039: harden against unnamed sockets */ + if (adr_len > (char *)&(adr->s_unix.sun_path) - (char *)&(adr->s_unix)) + path = adr->s_unix.sun_path; + else + path = ""; + n = copy_string(path); Begin_root (n); res = alloc_small(1, 0); Field(res,0) = n; |