summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkImgGIF.c8
-rw-r--r--tests/corruptTruncatedColormap.gifbin0 -> 10 bytes
-rw-r--r--tests/imgPhoto.test17
3 files changed, 24 insertions, 1 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 7e237fa..549a997 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -466,7 +466,13 @@ FileReadGIF(
*/
if (Fread(gifConfPtr, buf, 1, 3, chan) != 3) {
- return TCL_OK;
+ /*
+ * Bug [865af0148c]: 3 bytes should be there, but data ended before
+ */
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "GIF file truncated", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "TRUNCATED", NULL);
+ return TCL_ERROR;
}
bitPixel = 2 << (buf[0] & 0x07);
diff --git a/tests/corruptTruncatedColormap.gif b/tests/corruptTruncatedColormap.gif
new file mode 100644
index 0000000..21d4add
--- /dev/null
+++ b/tests/corruptTruncatedColormap.gif
Binary files differ
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index 23a80dd..34107cc 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -1304,6 +1304,23 @@ test imgPhoto-18.6 {Reject truncated GIF (file)} -setup {
} -cleanup {
catch {image delete gif1}
} -returnCodes error -result {error reading color map}
+test imgPhoto-18.6.1 {Reject truncated GIF in Colormap - ticket 865af0148c - file} -setup {
+ set fileName [file join [file dirname [info script]] corruptTruncatedColormap.gif]
+} -body {
+ image create photo gif1 -file $fileName
+} -cleanup {
+ catch {image delete gif1}
+} -returnCodes error -result {GIF file truncated}
+test imgPhoto-18.6.2 {Reject truncated GIF in Colormap - ticket 865af0148c - data} -setup {
+ set fileName [file join [file dirname [info script]] corruptTruncatedColormap.gif]
+ set h [open $fileName rb]
+ set d [read $h]
+ close $h
+} -body {
+ image create photo gif1 -data $d
+} -cleanup {
+ catch {image delete gif1}
+} -returnCodes error -result {GIF file truncated}
test imgPhoto-18.7 {Reject corrupted GIF (> 4Gb) (binary string)} -constraints {
nonPortable
} -setup {