Mercurial > dropbear
diff svr-authpubkey.c @ 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 | d39cfedaf015 |
children | 5d8dbb6fdab7 |
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; } }