From b73a96938d0fc932a9d498359c98f4cf6ef34160 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 17 Jan 2018 18:12:16 +0000 Subject: Correctly handle errors when starting jpeg codec The current implementation treats both returning false and longjmp'ing out of jpeg_start_decompress as indicating that the decompression has paused and needs more data. This is incorrect, in reality only the false return value indicates this. The longjmp path indicates a fatal error in the processing of the jpeg. The default implementation actually calls exit() in this case, and the documentation explicitly calls out that in this case recovery isn't possible and the decode process will have to start from scratch. This resolves a situation where the progressive decoder would get a malformed jpeg and keep on grabbing blocks from it and try to start decoding it. This would eventually fail when it ran out of data to read, but would cause a large memory leak and a crash on the MSAN fuzzers. BUG=pdfium:986,chromium:798665 Change-Id: Ifd2ed7a2dc46fa20bab34e9c461a8d4c4718c4d7 Reviewed-on: https://pdfium-review.googlesource.com/23072 Reviewed-by: dsinclair Commit-Queue: Ryan Harrison --- core/fxcodec/codec/ccodec_jpegmodule.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/fxcodec/codec/ccodec_jpegmodule.h') diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h index 9f4c80d08d..aed01bda9b 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.h +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -7,6 +7,7 @@ #ifndef CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_ #define CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_ +#include #include #include "core/fxcrt/fx_system.h" @@ -24,6 +25,7 @@ class CCodec_JpegModule { class Context { public: virtual ~Context() {} + virtual jmp_buf* GetJumpMark() = 0; }; std::unique_ptr CreateDecoder(const uint8_t* src_buf, -- cgit v1.2.3