699c67
From c558baf01a97aed376a67ff4641f1c3c864ae3f0 Mon Sep 17 00:00:00 2001
699c67
From: Lumir Balhar <lbalhar@redhat.com>
699c67
Date: Thu, 8 Apr 2021 17:55:26 +0200
699c67
Subject: [PATCH 1/4] CVE-2021-25290
699c67
699c67
---
699c67
 src/libImaging/TiffDecode.c | 5 +++++
699c67
 1 file changed, 5 insertions(+)
699c67
699c67
diff --git a/src/libImaging/TiffDecode.c b/src/libImaging/TiffDecode.c
699c67
index f292da3..d17b557 100644
699c67
--- a/src/libImaging/TiffDecode.c
699c67
+++ b/src/libImaging/TiffDecode.c
699c67
@@ -36,6 +36,11 @@ tsize_t _tiffReadProc(thandle_t hdata, tdata_t buf, tsize_t size) {
699c67
 	TRACE(("_tiffReadProc: %d \n", (int)size));
699c67
 	dump_state(state);
699c67
 
699c67
+    if (state->loc > state->eof) {
699c67
+        TIFFError("_tiffReadProc", "Invalid Read at loc %d, eof: %d", state->loc, state->eof);
699c67
+        return 0;
699c67
+    }
699c67
+
699c67
 	to_read = min(size, min(state->size, (tsize_t)state->eof) - (tsize_t)state->loc);
699c67
 	TRACE(("to_read: %d\n", (int)to_read));
699c67
 
699c67
-- 
699c67
2.30.2
699c67