From dc92574c10f3e2516ec6445b88c5d584f40df4e5 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 4 Jan 2021 11:55:28 -0500 Subject: [PATCH] Fix some pipelines to be safe if downstream write fails (fuzz issue 28262) --- ChangeLog | 6 ++++++ fuzz/qpdf_extra/28262.fuzz | Bin 0 -> 40395 bytes libqpdf/Pl_AES_PDF.cc | 2 +- libqpdf/Pl_ASCII85Decoder.cc | 7 +++++-- libqpdf/Pl_ASCIIHexDecoder.cc | 6 ++++-- libqpdf/Pl_Count.cc | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 fuzz/qpdf_extra/28262.fuzz diff --git a/ChangeLog b/ChangeLog index 2db53cb8..1e31efb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-01-04 Jay Berkenbilt + + * Move getNext()->write() calls in some pipelines to ensure that + state gates properly reset even if the next pipeline's write + throws an exception (fuzz issue 28262). + 2021-01-03 Jay Berkenbilt * Don't include -o nospace with zsh completion setup so file diff --git a/fuzz/qpdf_extra/28262.fuzz b/fuzz/qpdf_extra/28262.fuzz new file mode 100644 index 0000000000000000000000000000000000000000..4e872ba414db50c17dd8725c2d467df44ac6ea58 GIT binary patch literal 40395 zcmeHw2V7Iv+dp+1#jV9r4SRF%&A2yV6ZVF%M}Uw4fec83B3k#h;;f2RZLOp3tyR%# z-FvS(s&(&zd%x%2n;Wuhp}$|{|Gt0ud{A<7=J!13InQ~X=R8NF6{@x6YKfHQiKz06 ztbKi<7@1NcRLd$PVmboF*diDTGoW}n1BF8A94?mw#nBm1G9AGf92knAXVF<4E*;^r z1pfZk5~Ucgg>L=>#R(M>gsy8NL?Tj&B?&^cLIYY1R>{j0N)4R_C8#B0nMkWr(-DTh zKNKdDYb9zZOfJ+)$Rbc=NR}@W63PhXvY1>(SSS+2V(~&TE)o>V3&9X}D1wCg|9uVt z6sZ(T%Ci_OI+IOD5jujWNL6$OlMd7QP>e)bpe>|x5WGu$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DV7f^2ZE6}pM${uzTguB ykubruvw+CR7Jwrite(this->outbuf, bytes); this->offset = 0; + getNext()->write(this->outbuf, bytes); } diff --git a/libqpdf/Pl_ASCII85Decoder.cc b/libqpdf/Pl_ASCII85Decoder.cc index b8df3e87..9d9f6704 100644 --- a/libqpdf/Pl_ASCII85Decoder.cc +++ b/libqpdf/Pl_ASCII85Decoder.cc @@ -119,10 +119,13 @@ Pl_ASCII85Decoder::flush() QTC::TC("libtests", "Pl_ASCII85Decoder partial flush", (this->pos == 5) ? 0 : 1); - getNext()->write(outbuf, this->pos - 1); - + // Reset before calling getNext()->write in case that throws an + // exception. + auto t = this->pos - 1; this->pos = 0; memset(this->inbuf, 117, 5); + + getNext()->write(outbuf, t); } void diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc index f20a9769..7845268e 100644 --- a/libqpdf/Pl_ASCIIHexDecoder.cc +++ b/libqpdf/Pl_ASCIIHexDecoder.cc @@ -97,12 +97,14 @@ Pl_ASCIIHexDecoder::flush() QTC::TC("libtests", "Pl_ASCIIHexDecoder partial flush", (this->pos == 2) ? 0 : 1); - getNext()->write(&ch, 1); - + // Reset before calling getNext()->write in case that throws an + // exception. this->pos = 0; this->inbuf[0] = '0'; this->inbuf[1] = '0'; this->inbuf[2] = '\0'; + + getNext()->write(&ch, 1); } void diff --git a/libqpdf/Pl_Count.cc b/libqpdf/Pl_Count.cc index 8077092a..c35619b8 100644 --- a/libqpdf/Pl_Count.cc +++ b/libqpdf/Pl_Count.cc @@ -27,8 +27,8 @@ Pl_Count::write(unsigned char* buf, size_t len) if (len) { this->m->count += QIntC::to_offset(len); - getNext()->write(buf, len); this->m->last_char = buf[len - 1]; + getNext()->write(buf, len); } }