mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-19 08:46:44 +01:00
Merge pull request #3921 from bluca/fuzzers
Problem: invalid address results in out-of-range string access
This commit is contained in:
commit
8df0d99cd8
@ -1221,6 +1221,12 @@ install-data-hook:
|
||||
mv $(DESTDIR)/$(FUZZINGdir)/test_connect_null_fuzzer.seed $(DESTDIR)/$(FUZZINGdir)/$$fn; \
|
||||
zip -j -m -g --quiet $(DESTDIR)/$(FUZZINGdir)/test_connect_null_fuzzer_seed_corpus.zip $(DESTDIR)/$(FUZZINGdir)/$$fn; \
|
||||
done < $(DESTDIR)/$(FUZZINGdir)/test_connect_null_fuzzer.txt)
|
||||
$(shell while read -r test; do \
|
||||
echo -n $$test | perl -e 'print pack "H*", <STDIN>' > $(DESTDIR)/$(FUZZINGdir)/test_bind_fuzzer.seed; \
|
||||
export fn=$$(cat $(DESTDIR)/$(FUZZINGdir)/test_bind_fuzzer.seed | sha1sum | awk '{print $$1}'); \
|
||||
mv $(DESTDIR)/$(FUZZINGdir)/test_bind_fuzzer.seed $(DESTDIR)/$(FUZZINGdir)/$$fn; \
|
||||
zip -j -m -g --quiet $(DESTDIR)/$(FUZZINGdir)/test_bind_fuzzer.zip $(DESTDIR)/$(FUZZINGdir)/$$fn; \
|
||||
done < $(DESTDIR)/$(FUZZINGdir)/test_bind_fuzzer.txt)
|
||||
rm -f $(DESTDIR)/$(FUZZINGdir)/*.txt
|
||||
else
|
||||
test_apps += tests/test_bind_null_fuzzer \
|
||||
|
@ -252,6 +252,10 @@ int zmq::ip_resolver_t::resolve (ip_addr_t *ip_addr_, const char *name_)
|
||||
|
||||
if (pos != std::string::npos) {
|
||||
std::string if_str = addr.substr (pos + 1);
|
||||
if (if_str.empty ()) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
addr = addr.substr (0, pos);
|
||||
|
||||
if (isalpha (if_str.at (0))) {
|
||||
|
1
tests/fuzzer_corpora/test_bind_fuzzer.txt
Normal file
1
tests/fuzzer_corpora/test_bind_fuzzer.txt
Normal file
@ -0,0 +1 @@
|
||||
77733a2f2f253a39
|
@ -53,10 +53,21 @@ extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
|
||||
#ifndef ZMQ_USE_FUZZING_ENGINE
|
||||
void test_bind_fuzzer ()
|
||||
{
|
||||
uint8_t buffer[32] = {0};
|
||||
uint8_t **data;
|
||||
size_t *len, num_cases = 0;
|
||||
if (fuzzer_corpus_encode ("tests/fuzzer_corpora/test_bind_fuzzer.txt",
|
||||
&data, &len, &num_cases)
|
||||
!= 0)
|
||||
exit (77);
|
||||
|
||||
TEST_ASSERT_SUCCESS_ERRNO (
|
||||
LLVMFuzzerTestOneInput (buffer, sizeof (buffer)));
|
||||
while (num_cases-- > 0) {
|
||||
TEST_ASSERT_SUCCESS_ERRNO (
|
||||
LLVMFuzzerTestOneInput (data[num_cases], len[num_cases]));
|
||||
free (data[num_cases]);
|
||||
}
|
||||
|
||||
free (data);
|
||||
free (len);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
|
Loading…
x
Reference in New Issue
Block a user