Skip to content

Commit ef312c7

Browse files
authored
Merge pull request #54 from drk1wi/copilot/deep-qa-quality-tool
Fixing small bug in fuzzer mode,
2 parents c5063e7 + e9123d2 commit ef312c7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/Fuzzer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,16 @@ std::vector<char> Fuzzer::GetFUZZ()
157157

158158
if (fgets(buf_file, BUFSIZE, this->fp_payloads) == NULL)
159159
{
160-
fprintf(stdout, "EOF of payload file\n");
160+
fprintf(stdout, "EOF of payload file, rewinding\n");
161161
fflush(stdout);
162+
rewind(this->fp_payloads);
163+
if (fgets(buf_file, BUFSIZE, this->fp_payloads) == NULL)
164+
buf_file[0] = '\0'; // payload file is empty, nothing to read
162165
}
163166

164167
str = std::string(buf_file);
165-
str.erase(str.size() - 1); //remove \n
168+
if (!str.empty() && str.back() == '\n') //remove trailing \n, if any
169+
str.erase(str.size() - 1);
166170
this->input_line = Utils::str2vector(str);
167171
}
168172

0 commit comments

Comments
 (0)