Mercurial > dropbear
changeset 1883:f54451afc046
use buf_getptr and m_free on every iteration before m_malloc to insure no memory leaks are happening
author | HansH111 <hans@atbas.org> |
---|---|
date | Tue, 15 Mar 2022 18:57:21 +0000 |
parents | 2839daa507b3 |
children | 75d6a9faf919 |
files | svr-authpubkey.c |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/svr-authpubkey.c Sun Mar 13 17:38:38 2022 +0000 +++ b/svr-authpubkey.c Tue Mar 15 18:57:21 2022 +0000 @@ -356,6 +356,11 @@ 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 @@ 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; } }