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;
}