mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
Add errno reset with strtoul call
Contaminated errno can happen before strtoul call, thereofore cleaning it before the call. The errno is not used for checking later in code if fail happens, therefore cleaning it right after error. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
07f4d5e723
commit
eb9dc8cfc4
@@ -1361,21 +1361,25 @@ int ssh_analyze_banner(ssh_session session, int server)
|
||||
* 012345678901234567890
|
||||
*/
|
||||
if (strlen(openssh) > 9) {
|
||||
errno = 0;
|
||||
major = strtoul(openssh + 8, &tmp, 10);
|
||||
if ((tmp == (openssh + 8)) ||
|
||||
((errno == ERANGE) && (major == ULONG_MAX)) ||
|
||||
((errno != 0) && (major == 0)) ||
|
||||
((major < 1) || (major > 100))) {
|
||||
/* invalid major */
|
||||
errno = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
minor = strtoul(openssh + 10, &tmp, 10);
|
||||
if ((tmp == (openssh + 10)) ||
|
||||
((errno == ERANGE) && (major == ULONG_MAX)) ||
|
||||
((errno != 0) && (major == 0)) ||
|
||||
(minor > 100)) {
|
||||
/* invalid minor */
|
||||
errno = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ static int is_openssh_client_new_enough(void) {
|
||||
((major < 1) || (major > 100))) {
|
||||
fprintf(stderr, "failed to parse OpenSSH client version, "
|
||||
"errno %d\n", errno);
|
||||
errno = 0;
|
||||
goto errversion;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user