options: Fail if no number was parsed

strtoul returns 0 if no valid character was parsed, which
can unwantedly misconfigure the options.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Norbert Pocs
2023-05-02 16:56:27 +02:00
committed by Andreas Schneider
parent a006d34372
commit 968e09aae0

View File

@@ -572,7 +572,9 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
}
i = strtol(q, &p, 10);
if (q == p) {
SSH_LOG(SSH_LOG_DEBUG, "No port number was parsed");
SAFE_FREE(q);
return -1;
}
SAFE_FREE(q);
if (i <= 0) {
@@ -774,7 +776,9 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
}
i = strtol(q, &p, 10);
if (q == p) {
SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
SAFE_FREE(q);
return -1;
}
SAFE_FREE(q);
if (i < 0) {
@@ -1986,7 +1990,9 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
}
i = strtol(q, &p, 10);
if (q == p) {
SAFE_FREE(q);
SSH_LOG(SSH_LOG_DEBUG, "No bind port was parsed");
SAFE_FREE(q);
return -1;
}
SAFE_FREE(q);
@@ -2013,7 +2019,9 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
}
i = strtol(q, &p, 10);
if (q == p) {
SAFE_FREE(q);
SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
SAFE_FREE(q);
return -1;
}
SAFE_FREE(q);