зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
a128a2cdc3
Коммит
8f1482536a
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче