diff options
author | plusun <tomsun.0.7@gmail.com> | 2018-08-06 07:41:26 +0000 |
---|---|---|
committer | plusun <tomsun.0.7@gmail.com> | 2018-08-06 07:41:26 +0000 |
commit | 29b0dd9a2f696c51eb0650367d032643fe770c79 (patch) | |
tree | dca1983d44c8fc53fff21ff785102899495e45f1 /mangle.c | |
parent | 0262b325d9259eebc259c3a7b936573cfc3ad545 (diff) | |
download | honggfuzz-29b0dd9a2f696c51eb0650367d032643fe770c79.tar.gz |
add 'NoCheck' version of mangle_DictionaryInsert to reduce duplicated code
Diffstat (limited to 'mangle.c')
-rw-r--r-- | mangle.c | 27 |
1 files changed, 10 insertions, 17 deletions
@@ -129,12 +129,7 @@ static void mangle_BitPrintable(run_t* run) { util_turnToPrintable(&(run->dynamicFile[off]), 1); } -static void mangle_DictionaryInsert(run_t* run) { - if (run->global->mutate.dictionaryCnt == 0) { - mangle_Bit(run); - return; - } - +static void mangle_DictionaryInsertNoCheck(run_t *run) { uint64_t choice = util_rndGet(0, run->global->mutate.dictionaryCnt - 1); struct strings_t* str = TAILQ_FIRST(&run->global->mutate.dictq); for (uint64_t i = 0; i < choice; i++) { @@ -147,22 +142,20 @@ static void mangle_DictionaryInsert(run_t* run) { mangle_Overwrite(run, (uint8_t*)str->s, off, str->len); } -static void mangle_DictionaryInsertPrintable(run_t* run) { +static void mangle_DictionaryInsert(run_t* run) { if (run->global->mutate.dictionaryCnt == 0) { - mangle_BitPrintable(run); + mangle_Bit(run); return; } + mangle_DictionaryInsertNoCheck(run); +} - uint64_t choice = util_rndGet(0, run->global->mutate.dictionaryCnt - 1); - struct strings_t* str = TAILQ_FIRST(&run->global->mutate.dictq); - for (uint64_t i = 0; i < choice; i++) { - str = TAILQ_NEXT(str, pointers); +static void mangle_DictionaryInsertPrintable(run_t* run) { + if (run->global->mutate.dictionaryCnt == 0) { + mangle_BitPrintable(run); + return; } - - size_t off = util_rndGet(0, run->dynamicFileSz - 1); - mangle_Inflate(run, off, str->len); - mangle_Move(run, off, off + str->len, str->len); - mangle_Overwrite(run, (uint8_t*)str->s, off, str->len); + mangle_DictionaryInsertNoCheck(run); } static void mangle_Dictionary(run_t* run) { |