mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-27 13:21:11 +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:
committed by
Sahana Prasad
parent
9f2b42382c
commit
6e834b8df2
10
src/pki.c
10
src/pki.c
@@ -1668,10 +1668,10 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
|
|||||||
{
|
{
|
||||||
enum ssh_keytypes_e type;
|
enum ssh_keytypes_e type;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *key_buf, *p;
|
char *key_buf = NULL, *p = NULL;
|
||||||
size_t buflen, i;
|
size_t buflen, i;
|
||||||
const char *q;
|
const char *q = NULL;
|
||||||
FILE *file;
|
FILE *file = NULL;
|
||||||
off_t size;
|
off_t size;
|
||||||
int rc, cmp;
|
int rc, cmp;
|
||||||
char err_msg[SSH_ERRNO_MSG_MAX] = {0};
|
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;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i >= buflen) {
|
||||||
|
SAFE_FREE(key_buf);
|
||||||
|
return SSH_ERROR;
|
||||||
|
}
|
||||||
q = &p[i + 1];
|
q = &p[i + 1];
|
||||||
for (; i < buflen; i++) {
|
for (; i < buflen; i++) {
|
||||||
if (isspace((int)p[i])) {
|
if (isspace((int)p[i])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user