kopia lustrzana https://github.com/weetmuts/wmbusmeters
Previous commit added better detection of amb8465 dongles. This commit removes unnecessary assert for length inside crc calculation. This check caused unnecessary fuzz crashes.
rodzic
837b86da85
commit
5793d7f5b7
19
src/fuzz.cc
19
src/fuzz.cc
|
@ -34,11 +34,20 @@ int main(int argc, char **argv)
|
||||||
// The binary difvif data is sent on stdin.
|
// The binary difvif data is sent on stdin.
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
vector<uchar> databytes;
|
vector<uchar> databytes;
|
||||||
|
vector<char> *ptr = reinterpret_cast<vector<char>*>(&databytes);
|
||||||
for (;;) {
|
if (argc > 1 && argv[1][0] != 0)
|
||||||
size_t len = read(0, buf, sizeof(buf));
|
{
|
||||||
if (len <= 0) break;
|
// Read from file.
|
||||||
databytes.insert(databytes.end(), buf, buf+len);
|
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<string,pair<int,DVEntry>> values;
|
map<string,pair<int,DVEntry>> values;
|
||||||
|
|
|
@ -1051,8 +1051,9 @@ uint16_t crc16_EN13757(uchar *data, size_t len)
|
||||||
uint16_t crc = 0x0000;
|
uint16_t crc = 0x0000;
|
||||||
|
|
||||||
assert(len == 0 || data != NULL);
|
assert(len == 0 || data != NULL);
|
||||||
assert(len < 1024);
|
|
||||||
for (size_t i=0; i<len; ++i) {
|
for (size_t i=0; i<len; ++i)
|
||||||
|
{
|
||||||
crc = crc16_EN13757_per_byte(crc, data[i]);
|
crc = crc16_EN13757_per_byte(crc, data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue