From 12f1eb15ca3fed6310402847559a7c99d3c77847 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 2 Apr 2022 17:14:10 -0400 Subject: Programmatically apply new formatting to code Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done --- fuzz/qpdf_fuzzer.cc | 83 ++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 45 deletions(-) (limited to 'fuzz/qpdf_fuzzer.cc') diff --git a/fuzz/qpdf_fuzzer.cc b/fuzz/qpdf_fuzzer.cc index 9f0d5d39..3c76bbc9 100644 --- a/fuzz/qpdf_fuzzer.cc +++ b/fuzz/qpdf_fuzzer.cc @@ -1,22 +1,30 @@ -#include -#include -#include -#include #include +#include #include +#include +#include +#include #include -#include #include -#include -#include +#include +#include +#include #include class DiscardContents: public QPDFObjectHandle::ParserCallbacks { public: - virtual ~DiscardContents() {} - virtual void handleObject(QPDFObjectHandle) {} - virtual void handleEOF() {} + virtual ~DiscardContents() + { + } + virtual void + handleObject(QPDFObjectHandle) + { + } + virtual void + handleEOF() + { + } }; class FuzzHelper @@ -66,16 +74,11 @@ FuzzHelper::getWriter(PointerHolder qpdf) void FuzzHelper::doWrite(PointerHolder w) { - try - { + try { w->write(); - } - catch (QPDFExc const& e) - { + } catch (QPDFExc const& e) { std::cerr << e.what() << std::endl; - } - catch (std::runtime_error const& e) - { + } catch (std::runtime_error const& e) { std::cerr << e.what() << std::endl; } } @@ -133,14 +136,12 @@ FuzzHelper::testPages() std::vector pages = pdh.getAllPages(); DiscardContents discard_contents; int pageno = 0; - for (std::vector::iterator iter = - pages.begin(); - iter != pages.end(); ++iter) - { + for (std::vector::iterator iter = pages.begin(); + iter != pages.end(); + ++iter) { QPDFPageObjectHelper& page(*iter); ++pageno; - try - { + try { page.coalesceContentStreams(); page.parseContents(&discard_contents); page.getImages(); @@ -153,16 +154,13 @@ FuzzHelper::testPages() afdh.getWidgetAnnotationsForPage(page); for (std::vector::iterator annot_iter = annotations.begin(); - annot_iter != annotations.end(); ++annot_iter) - { + annot_iter != annotations.end(); + ++annot_iter) { QPDFAnnotationObjectHelper& aoh = *annot_iter; afdh.getFieldForAnnotation(aoh); } - } - catch (QPDFExc& e) - { - std::cerr << "page " << pageno << ": " - << e.what() << std::endl; + } catch (QPDFExc& e) { + std::cerr << "page " << pageno << ": " << e.what() << std::endl; } } } @@ -171,16 +169,15 @@ void FuzzHelper::testOutlines() { PointerHolder q = getQpdf(); - std::list > queue; + std::list> queue; QPDFOutlineDocumentHelper odh(*q); queue.push_back(odh.getTopLevelOutlines()); - while (! queue.empty()) - { + while (!queue.empty()) { std::vector& outlines = *(queue.begin()); for (std::vector::iterator iter = outlines.begin(); - iter != outlines.end(); ++iter) - { + iter != outlines.end(); + ++iter) { QPDFOutlineObjectHelper& ol = *iter; ol.getDestPage(); queue.push_back(ol.getKids()); @@ -208,21 +205,17 @@ FuzzHelper::run() // std::runtime_error. Throwing any other kind of exception, // segfaulting, or having a memory error (when built with // appropriate sanitizers) will all cause abnormal exit. - try - { + try { doChecks(); - } - catch (QPDFExc const& e) - { + } catch (QPDFExc const& e) { std::cerr << "QPDFExc: " << e.what() << std::endl; - } - catch (std::runtime_error const& e) - { + } catch (std::runtime_error const& e) { std::cerr << "runtime_error: " << e.what() << std::endl; } } -extern "C" int LLVMFuzzerTestOneInput(unsigned char const* data, size_t size) +extern "C" int +LLVMFuzzerTestOneInput(unsigned char const* data, size_t size) { #ifndef _WIN32 // Used by jpeg library to work around false positives in memory -- cgit v1.2.3-54-g00ecf