From 5793d7f5b75b03bc8b4ca98500f63c112d27cff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20=C3=96hrstr=C3=B6m?= Date: Mon, 9 Aug 2021 01:10:13 +0200 Subject: [PATCH] Previous commit added better detection of amb8465 dongles. This commit removes unnecessary assert for length inside crc calculation. This check caused unnecessary fuzz crashes. --- src/fuzz.cc | 19 ++++++++++++++----- src/util.cc | 5 +++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/fuzz.cc b/src/fuzz.cc index 03d1c25..bdfa371 100644 --- a/src/fuzz.cc +++ b/src/fuzz.cc @@ -34,11 +34,20 @@ int main(int argc, char **argv) // The binary difvif data is sent on stdin. char buf[1024]; vector databytes; - - for (;;) { - size_t len = read(0, buf, sizeof(buf)); - if (len <= 0) break; - databytes.insert(databytes.end(), buf, buf+len); + vector *ptr = reinterpret_cast*>(&databytes); + if (argc > 1 && argv[1][0] != 0) + { + // Read from file. + loadFile(string(argv[1]), ptr); + } + else + { + // Read from stdin + for (;;) { + size_t len = read(0, buf, sizeof(buf)); + if (len <= 0) break; + databytes.insert(databytes.end(), buf, buf+len); + } } map> values; diff --git a/src/util.cc b/src/util.cc index 1dd35e6..460f5a2 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1051,8 +1051,9 @@ uint16_t crc16_EN13757(uchar *data, size_t len) uint16_t crc = 0x0000; assert(len == 0 || data != NULL); - assert(len < 1024); - for (size_t i=0; i