Skip to content

Commit

Permalink
[server] Fix ASAN-triggered crash in AFL fuzzing mode
Browse files Browse the repository at this point in the history
This fixes a crash in initialization code when fwknopd is compiled
with ASAN support in AFL fuzzing mode via the
'afl/fuzzing-wrappers/server-enc-pkts.sh' wrapper script. This crash
is not in operational fwknop code - only special code that is
compiled in AFL mode.
  • Loading branch information
mrash committed Feb 6, 2024
1 parent 792dee6 commit db902cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/fwknopd.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void enable_fault_injections(fko_srv_options_t * const opts);
#endif

#if AFL_FUZZING
#define AFL_MAX_PKT_SIZE 1024
#define AFL_MAX_PKT_SIZE MAX_SPA_ENCODED_MSG_SIZE
#define AFL_DUMP_CTX_SIZE 4096
#endif

Expand Down Expand Up @@ -376,10 +376,11 @@ static void afl_enc_pkt_from_file(fko_srv_options_t *opts)
{
enc_spa_pkt[enc_msg_len] = rc;
enc_msg_len++;
if(enc_msg_len == AFL_MAX_PKT_SIZE-1)
if(enc_msg_len == AFL_MAX_PKT_SIZE-2)
break;
}
fclose(fp);
enc_msg_len++;

fko_new(&decrypt_ctx);

Expand Down

0 comments on commit db902cf

Please sign in to comment.