Skip to contentSkip to conversation

Pass proper sockaddr_* structure for IPv6 socket errors.

PATCH In review Gert Doering 2 participants 3 messages May 13, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Pass proper sockaddr_* structure for IPv6 socket errors.

commit 043c67f363429 enhances format_extended_socket_error() by recognizing IPv6 extended socket errors, but neglected to change the "sockaddr_in" buffer passed to recvmsg() to "sockaddr_storage".

According to documentation, recvmsg() should not have overrun that structure (we pass the size of the struct), but according to ASAN it does... so, pass the correct structure.

---
 src/openvpn/mtu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/mtu.c +1 -1
index 93feaff1..84310349 100644
@@ -312,7 +312,7 @@ format_extended_socket_error(int fd, int *mtu, struct gc_arena *gc)
     struct msghdr msg;
     struct cmsghdr *cmsg;
     struct sock_extended_err *e;
-    struct sockaddr_in addr;
+    struct sockaddr_storage addr;
     struct buffer out = alloc_buf_gc(256, gc);
     char *cbuf = (char *) gc_malloc(256, false, gc);
 
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw

Am 13.05.22 um 12:15 schrieb Gert Doering:

Quoted 8 lines

commit 043c67f363429 enhances format_extended_socket_error() by recognizing IPv6 extended socket errors, but neglected to change the "sockaddr_in" buffer passed to recvmsg() to "sockaddr_storage".

According to documentation, recvmsg() should not have overrun that structure (we pass the size of the struct), but according to ASAN it does... so, pass the correct structure.

#2 lore raw
In reply to Gert Doering

Patch has been applied to the master branch.

commit c96249696cf6d6217443bc93f8208571f289623e

Author: Gert Doering
Date:   Fri May 13 12:15:26 2022 +0200
     Pass proper sockaddr_* structure for IPv6 socket errors.

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24352.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering