Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 968e09a

Browse files
Norbert Pocscryptomilk
authored andcommitted
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>
1 parent a006d34 commit 968e09a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/options.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,9 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
572572
}
573573
i = strtol(q, &p, 10);
574574
if (q == p) {
575+
SSH_LOG(SSH_LOG_DEBUG, "No port number was parsed");
575576
SAFE_FREE(q);
577+
return -1;
576578
}
577579
SAFE_FREE(q);
578580
if (i <= 0) {
@@ -774,7 +776,9 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
774776
}
775777
i = strtol(q, &p, 10);
776778
if (q == p) {
779+
SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
777780
SAFE_FREE(q);
781+
return -1;
778782
}
779783
SAFE_FREE(q);
780784
if (i < 0) {
@@ -1986,7 +1990,9 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
19861990
}
19871991
i = strtol(q, &p, 10);
19881992
if (q == p) {
1989-
SAFE_FREE(q);
1993+
SSH_LOG(SSH_LOG_DEBUG, "No bind port was parsed");
1994+
SAFE_FREE(q);
1995+
return -1;
19901996
}
19911997
SAFE_FREE(q);
19921998

@@ -2013,7 +2019,9 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
20132019
}
20142020
i = strtol(q, &p, 10);
20152021
if (q == p) {
2016-
SAFE_FREE(q);
2022+
SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
2023+
SAFE_FREE(q);
2024+
return -1;
20172025
}
20182026
SAFE_FREE(q);
20192027

0 commit comments

Comments
 (0)