summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a128a2c)
raw | patch | inline | side by side (parent: a128a2c)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sun, 21 Dec 2008 01:12:11 +0000 (02:12 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 21 Dec 2008 09:48:23 +0000 (01:48 -0800) |
In addition to checking if the provided port is numeric, also check
that the string isn't empty and that the port number is within the
valid range. Incidentally, this silences a compiler warning about
ignoring strtol's return value.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
that the string isn't empty and that the port number is within the
valid range. Incidentally, this silences a compiler warning about
ignoring strtol's return value.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
connect.c | patch | blob | history |
diff --git a/connect.c b/connect.c
index 584e04c217da4ea8943e33c77fea56ce64547ed1..2f55ad2c256bc01b3062b99251af4386eef5af22 100644 (file)
--- a/connect.c
+++ b/connect.c
char *p = strchr(host, ':');
if (p) {
- strtol(p+1, &end, 10);
- if (*end == '\0') {
+ long port = strtol(p + 1, &end, 10);
+ if (end != p + 1 && *end == '\0' && 0 <= port && port < 65536) {
*p = '\0';
return p+1;
}