Skip to content

Commit

Permalink
Merge commit '11d1556127d2aa60cb9bf5ea2e429ab86cf5912e'
Browse files Browse the repository at this point in the history
  • Loading branch information
kdart committed May 1, 2022
2 parents ab1f838 + 11d1556 commit 4216b94
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libssh2/src/userauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,22 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
return NULL;
}
banner_len = _libssh2_ntohu32(session->userauth_list_data + 1);
if(banner_len >= session->userauth_list_data_len - 5) {
if(banner_len > session->userauth_list_data_len - 5) {
LIBSSH2_FREE(session, session->userauth_list_data);
session->userauth_list_data = NULL;
_libssh2_error(session, LIBSSH2_ERROR_OUT_OF_BOUNDARY,
"Unexpected userauth banner size");
return NULL;
}
session->userauth_banner = LIBSSH2_ALLOC(session, banner_len);
session->userauth_banner = LIBSSH2_ALLOC(session, banner_len + 1);
if(!session->userauth_banner) {
LIBSSH2_FREE(session, session->userauth_list_data);
session->userauth_list_data = NULL;
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for userauth_banner");
return NULL;
}
memmove(session->userauth_banner, session->userauth_list_data + 5,
memcpy(session->userauth_banner, session->userauth_list_data + 5,
banner_len);
session->userauth_banner[banner_len] = '\0';
_libssh2_debug(session, LIBSSH2_TRACE_AUTH,
Expand Down

0 comments on commit 4216b94

Please sign in to comment.