1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-10-30 12:05:34 +03:00

fix two NULL checks

- userauth: fix NULL dereference when out-of-memory.
  Also fix indentation.
  Follow-up to 3a6ab70dcf #1314

- openssl: drop redundant NULL check and logic.
  Follow-up to ed439a29bb #698

Pointed out by CodeQL

Closes #1656
This commit is contained in:
Viktor Szakats
2025-09-14 00:38:47 +02:00
parent 199526f941
commit 51b35d1b7a
2 changed files with 4 additions and 7 deletions

View File

@@ -3848,11 +3848,7 @@ gen_publickey_from_sk_ecdsa_openssh_priv_data(LIBSSH2_SESSION *session,
LIBSSH2_FREE(session, *pubkeydata);
*pubkeydata_len = key_len;
if(pubkeydata)
*pubkeydata = key;
else if(key)
LIBSSH2_FREE(session, key);
*pubkeydata = key;
}
if(ec_ctx)

View File

@@ -1492,7 +1492,8 @@ _libssh2_key_sign_algorithm(LIBSSH2_SESSION *session,
if(match) {
if(*key_method_len == 28 &&
memcmp(key_method, "ssh-rsa-cert-v01@openssh.com", *key_method_len)) {
memcmp(key_method,
"ssh-rsa-cert-v01@openssh.com", *key_method_len)) {
if(*key_method)
LIBSSH2_FREE(session, *key_method);
*key_method = LIBSSH2_ALLOC(session, match_len + suffix_len);
@@ -1511,7 +1512,7 @@ _libssh2_key_sign_algorithm(LIBSSH2_SESSION *session,
*key_method_len = match_len;
}
}
if(!key_method) {
if(!*key_method) {
*key_method_len = 0;
rc = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate key method upgrade");