[vlc-commits] net: drop trailing new line in proxy URL

Rémi Denis-Courmont git at videolan.org
Fri Apr 12 18:33:34 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Apr 12 19:33:04 2013 +0300| [1fe855412ad080e868946cc029f6ada101b4f187] | committer: Rémi Denis-Courmont

net: drop trailing new line in proxy URL

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1fe855412ad080e868946cc029f6ada101b4f187
---

 src/posix/netconf.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/posix/netconf.c b/src/posix/netconf.c
index f5a61c3..9e794bb 100644
--- a/src/posix/netconf.c
+++ b/src/posix/netconf.c
@@ -95,12 +95,16 @@ char *vlc_getProxyUrl(const char *url)
         close(fd[0]);
         while (waitpid(pid, &(int){ 0 }, 0) == -1);
 
-        if (len >= sizeof (buf))
-            return NULL; /* overflow */
         if (len >= 9 && !strncasecmp(buf, "direct://", 9))
             return NULL;
-        if (len > 0)
-            return strndup(buf, len);
+
+        char *end = memchr(buf, '\n', len);
+        if (end != NULL)
+        {
+            *end = '\0';
+            return strdup(buf);
+        }
+        /* Parse error: fallback (may be due to missing executable) */
     }
     else
         close(fd[0]);



More information about the vlc-commits mailing list