# HG changeset patch # User HansH111 # Date 1647370641 0 # Node ID f54451afc046259a519fe12e40d3b6a1fbe9fa99 # Parent 2839daa507b3e1cd34af8c4d810fb5f4b276a950 use buf_getptr and m_free on every iteration before m_malloc to insure no memory leaks are happening diff -r 2839daa507b3 -r f54451afc046 svr-authpubkey.c --- 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; } }