{"thread":{"id":"16814","subject":"[PATCH] connect.c: stricter port validation, silence compiler warning","startedAt":"2008-12-21T01:12:11Z","lastAt":"2008-12-21T01:12:11Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"98467","messageId":"1229821931.31765.12.camel@ubuntu.ubuntu-domain","threadId":"16814","inReplyTo":null,"subject":"[PATCH] connect.c: stricter port validation, silence compiler warning","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-12-21T01:12:11Z","receivedAt":"2008-12-21T01:12:11Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"In addition to checking if the provided port is numeric, also check\nthat the string isn't empty and that the port number is within the\nvalid range.  Incidentally, this silences a compiler warning about\nignoring strtol's return value.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n connect.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex 584e04c..2f55ad2 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -480,8 +480,8 @@ char *get_port(char *host)\n \tchar *p = strchr(host, ':');\n \n \tif (p) {\n-\t\tstrtol(p+1, &end, 10);\n-\t\tif (*end == '\\0') {\n+\t\tlong port = strtol(p + 1, &end, 10);\n+\t\tif (end != p + 1 && *end == '\\0' && 0 <= port && port < 65536) {\n \t\t\t*p = '\\0';\n \t\t\treturn p+1;\n \t\t}\n-- \n1.6.1.rc3.52.g589372\n"}]}