1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-26 01:03:15 +03:00

pki: Initialize pointers and avoid buffer overrun

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Jakub Jelen
2023-11-09 09:49:35 +01:00
committed by Sahana Prasad
parent 9f2b42382c
commit 6e834b8df2

View File

@@ -1668,10 +1668,10 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
{
enum ssh_keytypes_e type;
struct stat sb;
char *key_buf, *p;
char *key_buf = NULL, *p = NULL;
size_t buflen, i;
const char *q;
FILE *file;
const char *q = NULL;
FILE *file = NULL;
off_t size;
int rc, cmp;
char err_msg[SSH_ERRNO_MSG_MAX] = {0};
@@ -1777,6 +1777,10 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
return SSH_ERROR;
}
if (i >= buflen) {
SAFE_FREE(key_buf);
return SSH_ERROR;
}
q = &p[i + 1];
for (; i < buflen; i++) {
if (isspace((int)p[i])) {