Skip to content

Commit

Permalink
avoid leak of pubkey_options
Browse files Browse the repository at this point in the history
  • Loading branch information
mkj committed Mar 6, 2018
1 parent 4fd3160 commit e9edbe8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion fuzzer-pubkey.c
Expand Up @@ -30,10 +30,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (have_algo(algoname, algolen, sshhostkey) == DROPBEAR_FAILURE) {
dropbear_exit("fuzzer imagined a bogus algorithm");
}
fuzz_checkpubkey_line(line, 5, "/home/me/authorized_keys",

int ret = fuzz_checkpubkey_line(line, 5, "/home/me/authorized_keys",
algoname, algolen,
keyblob->data, keyblob->len);

if (ret == DROPBEAR_SUCCESS) {
/* fuzz_checkpubkey_line() should have cleaned up for failure */
svr_pubkey_options_cleanup();
}

buf_free(line);
buf_free(keyblob);
m_free(algoname);
Expand Down
4 changes: 4 additions & 0 deletions svr-authpubkey.c
Expand Up @@ -167,6 +167,10 @@ void svr_auth_pubkey() {
sign_key_free(key);
key = NULL;
}
/* Retain pubkey options only if auth succeeded */
if (!ses.authstate.authdone) {
svr_pubkey_options_cleanup();
}
TRACE(("leave pubkeyauth"))
}

Expand Down
1 change: 0 additions & 1 deletion svr-authpubkeyoptions.c
Expand Up @@ -113,7 +113,6 @@ void svr_pubkey_options_cleanup() {
m_free(ses.authstate.pubkey_options->forced_command);
}
m_free(ses.authstate.pubkey_options);
ses.authstate.pubkey_options = NULL;
}
}

Expand Down

0 comments on commit e9edbe8

Please sign in to comment.