[gimp] plug-ins: fix reading of FLI files where the filesize is off-by-on
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: fix reading of FLI files where the filesize is off-by-on
- Date: Mon, 16 May 2022 15:24:03 +0000 (UTC)
commit 980e604880785865aea41716af83e4268ecc3ecf
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon May 16 11:21:57 2022 -0400
plug-ins: fix reading of FLI files where the filesize is off-by-on
plug-ins/file-fli/fli.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/file-fli/fli.c b/plug-ins/file-fli/fli.c
index 7343817781..88ae239439 100644
--- a/plug-ins/file-fli/fli.c
+++ b/plug-ins/file-fli/fli.c
@@ -197,9 +197,15 @@ fli_read_header (FILE *f,
if (actual_size != fli_header->filesize && actual_size >= 0)
{
- g_warning (_("Incorrect file size in header: %u, should be: %u."),
- fli_header->filesize, (guint) actual_size);
- fli_header->filesize = actual_size;
+ /* Older versions of GIMP or other apps may incorrectly finish chunks on
+ * an odd length, but write filesize as if that last byte was written.
+ * Don't fail on off-by-one file size. */
+ if (actual_size + 1 != fli_header->filesize)
+ {
+ g_warning (_("Incorrect file size in header: %u, should be: %u."),
+ fli_header->filesize, (guint) actual_size);
+ fli_header->filesize = actual_size;
+ }
}
if (fli_header->frames == 0)
@@ -341,7 +347,7 @@ fli_read_frame (FILE *f,
}
g_debug ("Chunk offset: %u, chunk size: %u, chunk type: %u",
(guint) chunkpos, chunk.size, chunk.magic);
- if (chunkpos + chunk.size >= fli_header->filesize)
+ if (chunkpos + chunk.size > fli_header->filesize)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Invalid chunk size points past end of file!"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]