commit 669790f191189a4e1c9416572909dd3a158547f5 from: xentrac date: Fri Feb 26 04:01:06 2021 UTC Report incorrect /Filter type with decode failure Previously, when the instigator produced a PDF file with a stream with `<>` in its stream dictionary, pdf was failing by aborting with an assert failure. An assert failure is not the right way to report that the program’s input is invalid. This change simply returns NULL from `decode_stream` in this case. commit - c9ab81f899e5ed4668d95cf5d250364c5ba50922 commit + 669790f191189a4e1c9416572909dd3a158547f5 blob - c2d370e2a67ee3320b3b7ed10179087ef21e2ecb blob + a559b5fa565035ded75e18332670c06ebd382dc4 --- pdf.c +++ pdf.c @@ -1902,9 +1902,12 @@ decode_stream(const Dict *d, HBytes b, HParser *p) errx(1, "stream data parser: LL(1) compile failed"); #endif - if (v->token_type == TT_SEQUENCE) - return NULL; // XXX filter chains not supported, yet - assert(v->token_type == TT_BYTES); + if (v->token_type != TT_BYTES) { + // XXX TT_SEQUENCE would be a filter chains; that’s not supported, yet. + // But it might also be something bogus, in which case we should fail. + return NULL; + } + if (bytes_eq(v->bytes, "FlateDecode")) filter = FlateDecode; else if (bytes_eq(v->bytes, "ASCIIHexDecode"))