Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
248631ae by Alaric Senat at 2022-06-23T06:17:13+00:00
contrib: upnp: fix bind failures for non-IPv6 netintf

This patch fixes issues when a net intf provides only one version of the
IP protocol when libupnp is built with `--enable-ipv6`.

This has been proposed upstream: https://github.com/pupnp/pupnp/pull/398

Refs #27001

- - - - -


2 changed files:

- + contrib/src/upnp/miniserver-pton-error.patch
- contrib/src/upnp/rules.mak


Changes:

=====================================
contrib/src/upnp/miniserver-pton-error.patch
=====================================
@@ -0,0 +1,38 @@
+From 06b60ad252d962b21071f157ec0c377c66b2492b Mon Sep 17 00:00:00 2001
+From: Alaric Senat <dev.ase...@posteo.net>
+Date: Thu, 9 Jun 2022 15:19:23 +0200
+Subject: [PATCH] miniserver: Don't initialize sockets for invalid IPs
+
+`init_socket_stuff` was ignoring `inet_pton`'s return value causing
+invalid IPs being seen as valid which caused bad calls to `bind` and
+`listen` further in the code path.
+
+Invalid `bind`s were frequents for interfaces providing only one IP
+protocol version (IPv4 or v6). In those cases, `gIF_IPV4` or `gIF_IPV4`
+were left to their default values (an empty string) causing `inet_pton`
+to fail silently without aborting the socket opening and binding...
+
+Refs #195
+---
+ upnp/src/genlib/miniserver/miniserver.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/upnp/src/genlib/miniserver/miniserver.c 
b/upnp/src/genlib/miniserver/miniserver.c
+index 1a313a36..09fe3fbf 100644
+--- a/upnp/src/genlib/miniserver/miniserver.c
++++ b/upnp/src/genlib/miniserver/miniserver.c
+@@ -756,7 +756,10 @@ static int init_socket_suff(
+               goto error;
+               break;
+       }
+-      inet_pton(domain, text_addr, addr);
++
++      if (inet_pton(domain, text_addr, addr) <= 0)
++        goto error;
++
+       s->fd = socket(domain, SOCK_STREAM, 0);
+       if (s->fd == INVALID_SOCKET) {
+               strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+-- 
+2.35.3
+


=====================================
contrib/src/upnp/rules.mak
=====================================
@@ -54,6 +54,7 @@ ifdef HAVE_ANDROID
 endif
        $(APPLY) $(SRC)/upnp/miniserver.patch
        $(APPLY) $(SRC)/upnp/upnp-no-debugfile.patch
+       $(APPLY) $(SRC)/upnp/miniserver-pton-error.patch
        $(UPDATE_AUTOCONFIG)
        $(MOVE)
 



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/248631aece4ff14684c87ece45e7685b49e9cdd7

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/248631aece4ff14684c87ece45e7685b49e9cdd7
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to