diff --git a/src/seeder/dns.cpp b/src/seeder/dns.cpp --- a/src/seeder/dns.cpp +++ b/src/seeder/dns.cpp @@ -64,6 +64,9 @@ int parse_name(const uint8_t **inpos, const uint8_t *inend, const uint8_t *inbuf, char *buf, size_t bufsize) { + if (bufsize == 0) { + return -2; + } size_t bufused = 0; int init = 1; do { diff --git a/src/seeder/test/dns_tests.cpp b/src/seeder/test/dns_tests.cpp --- a/src/seeder/test/dns_tests.cpp +++ b/src/seeder/test/dns_tests.cpp @@ -62,7 +62,7 @@ } // Test when the buffer size is too small - size_t outputBufferSize = 1; + size_t outputBufferSize = 0; while (outputBufferSize <= queryName.size()) { std::vector<char> parsedQueryName(outputBufferSize, 0); const uint8_t *nameFieldBegin = nameField.data();