[Openvpn-devel] Pass proper sockaddr_* structure for IPv6 socket errors.

Message ID 20220513101526.11486-1-gert@greenie.muc.de
State Accepted
Headers show
Series
  • [Openvpn-devel] Pass proper sockaddr_* structure for IPv6 socket errors.
Related show

Commit Message

Gert Doering May 13, 2022, 10:15 a.m.
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.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
 src/openvpn/mtu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arne Schwabe May 13, 2022, 11:17 a.m. | #1
Am 13.05.22 um 12:15 schrieb Gert Doering:
> 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.
> 

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering May 13, 2022, 12:18 p.m. | #2
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 <gert@greenie.muc.de>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20220513101526.11486-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24352.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/mtu.c b/src/openvpn/mtu.c
index 93feaff1..84310349 100644
--- a/src/openvpn/mtu.c
+++ b/src/openvpn/mtu.c
@@ -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);