[vlc-commits] url: return an error if the port is not a number (fixes #17555)
Rémi Denis-Courmont
git at videolan.org
Thu Oct 27 17:32:43 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 27 18:31:38 2016 +0300| [af2bcdfc1619e040b759ed07563cd90c9a56a7fb] | committer: Rémi Denis-Courmont
url: return an error if the port is not a number (fixes #17555)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=af2bcdfc1619e040b759ed07563cd90c9a56a7fb
---
src/text/url.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/text/url.c b/src/text/url.c
index 6116893..90a51cb 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -24,6 +24,7 @@
#endif
#include <errno.h>
+#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -525,7 +526,18 @@ int vlc_UrlParse(vlc_url_t *restrict url, const char *str)
/* Port number */
if (next != NULL)
- url->i_port = atoi(next);
+ {
+ char *end;
+ unsigned long u = strtoul(next, &end, 10);
+
+ url->i_port = u;
+ if (end == next || *end != '\0' || u == ULONG_MAX)
+ ret = -1;
+#if (ULONG_MAX > UINT_MAX)
+ if (u > UINT_MAX)
+ ret = -1;
+#endif
+ }
if (url->psz_path != NULL)
*url->psz_path = '/'; /* restore leading slash */
More information about the vlc-commits
mailing list