diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2008-12-21 02:12:11 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-12-21 01:48:23 -0800 |
commit | 8f1482536ad680fcd738158e76e254a534f2e690 (patch) | |
tree | 2b3b49ebe6e1c9a894b80250c9efcc04c47df5ff /connect.c | |
parent | a128a2cdc35cdf0eff7eeb1c21b912209f133633 (diff) | |
download | git-8f1482536ad680fcd738158e76e254a534f2e690.tar.gz |
connect.c: stricter port validation, silence compiler warning
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>
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -480,8 +480,8 @@ char *get_port(char *host) 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; } |