input: set remaining file size to ' '/\x00 if resized
@@ -56,12 +56,15 @@ void input_setSize(run_t* run, size_t sz) {
if (sz > run->global->mutate.maxFileSz) {
PLOG_F("Too large size requested: %zu > maxSize: %zu", sz, run->global->mutate.maxFileSz);
}
- size_t old_sz = run->dynamicFileSz;
- run->dynamicFileSz = sz;
- if (run->global->cfg.only_printable && old_sz < sz) {
- memset(run->dynamicFile, ' ', sz - old_sz);
+ if (sz < run->dynamicFileSz) {
+ if (run->global->cfg.only_printable) {
+ memset(&run->dynamicFile[sz], ' ', run->dynamicFileSz - sz);
+ } else {
+ memset(&run->dynamicFile[sz], '\x00', run->dynamicFileSz - sz);
}
}
+ run->dynamicFileSz = sz;
+}
static bool input_getDirStatsAndRewind(honggfuzz_t* hfuzz) {
rewinddir(hfuzz->io.inputDirPtr);
