Skip to content

Commit

Permalink
Fix fuzzer find and clean up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
attah committed Jan 15, 2024
1 parent 4d331e4 commit bfa75b1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ analyze:
clang++ --analyze $(CXXFLAGS) lib/*.cpp utils/*.cpp

fuzz:
clang++ -g -O1 -fsanitize=fuzzer $(CXXFLAGS) -O1 lib/ippmsg.cpp lib/ippattr.cpp bytestream/bytestream.cpp -o $@
clang++ -g -O1 -fsanitize=fuzzer $(CXXFLAGS) -O1 -DFUZZ lib/ippmsg.cpp lib/ippattr.cpp bytestream/bytestream.cpp -o $@
4 changes: 2 additions & 2 deletions lib/ippattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ std::ostream& operator<<(std::ostream& os, const IppValue& iv)
os << "{";
IppCollection ippCollection = iv.get<IppCollection>();
IppCollection::const_iterator it = ippCollection.cbegin();
os << "\"" << it->first << "\": " << it->second;
os << "\"" << it->first << "\": " << it->second.value();
it++;
for(; it != ippCollection.cend(); it++)
{
os << ", \"" << it->first << "\": " << it->second;
os << ", \"" << it->first << "\": " << it->second.value();
}
os << "}";
}
Expand Down
4 changes: 3 additions & 1 deletion lib/ippmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ IppMsg::IppMsg(Bytestream& bts)
}
else if (currentAttrType == UnsupportedAttrs)
{
#ifndef FUZZ // Too much spam for fuzzing
std::cerr << "WARNING: unsupported attrs reported: " << std::endl
<< attrs;
#endif
}

if(bts >>= EndAttrs)
Expand Down Expand Up @@ -278,7 +280,7 @@ IppValue IppMsg::collectAttributes(List<IppAttr>& attrs) const
}
else
{
std::cerr << "out of sync with collection" << tmpval.tag();
throw std::logic_error("out of sync with collection");
}
}

Expand Down
8 changes: 7 additions & 1 deletion lib/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define LIST_H

#include <list>
#include <stdexcept>

template <typename T>
class List: public std::list<T>
Expand All @@ -11,7 +12,12 @@ class List: public std::list<T>

T takeFront()
{
T tmp = std::list<T>::front();
if(std::list<T>::empty())
{
throw std::logic_error("List is empty");
}

T tmp(std::list<T>::front());
std::list<T>::pop_front();
return tmp;
}
Expand Down

0 comments on commit bfa75b1

Please sign in to comment.