diff options
author | HansH111 <hans@atbas.org> | 2022-03-15 18:57:21 +0000 |
---|---|---|
committer | HansH111 <hans@atbas.org> | 2022-03-15 18:57:21 +0000 |
commit | 39c131fb8321e6af4cefe59d92d7baf3be0ffb4c (patch) | |
tree | 31c00ca671823692bc166fd32537eae370c55f74 /svr-authpubkey.c | |
parent | fe5e923efedc6a664e6aeac563dbad5bcab1a01a (diff) | |
download | dropbear-39c131fb8321e6af4cefe59d92d7baf3be0ffb4c.tar.gz |
use buf_getptr and m_free on every iteration before m_malloc to insure no memory leaks are happening
Diffstat (limited to 'svr-authpubkey.c')
-rw-r--r-- | svr-authpubkey.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/svr-authpubkey.c b/svr-authpubkey.c index 10356a8..70e7f70 100644 --- a/svr-authpubkey.c +++ b/svr-authpubkey.c @@ -356,6 +356,11 @@ static int checkpubkey_line(buffer* line, int line_num, const char* filename, ret = cmp_base64_key(keyblob, keybloblen, (const unsigned char *) algo, algolen, line, NULL); + /* free pubkey_info if it is filled */ + if (ses.authstate.pubkey_info) { + m_free(ses.authstate.pubkey_info); + ses.authstate.pubkey_info = NULL; + } if (ret == DROPBEAR_SUCCESS) { if (options_buf) { ret = svr_add_pubkey_options(options_buf, line_num, filename); @@ -364,11 +369,9 @@ static int checkpubkey_line(buffer* line, int line_num, const char* filename, if (infolen) { ses.authstate.pubkey_info = m_malloc(infolen + 1); if (ses.authstate.pubkey_info) { - strncpy(ses.authstate.pubkey_info, &line->data[infopos], infolen); + strncpy(ses.authstate.pubkey_info,(const char *) buf_getptr(line, infopos), infolen); ses.authstate.pubkey_info[infolen]='\0'; } - } else { - ses.authstate.pubkey_info = NULL; } } |