From 7a2769cad7181a4ecf844714d0c06a423156b739 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sat, 9 Nov 2019 14:09:37 +0100 Subject: [PATCH] XPM loader: Accept signature not at the very start of the file --- src/modules/loaders/loader_xpm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/loaders/loader_xpm.c b/src/modules/loaders/loader_xpm.c index c18faa2..c35f32d 100644 --- a/src/modules/loaders/loader_xpm.c +++ b/src/modules/loaders/loader_xpm.c @@ -125,13 +125,14 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, if (!f) return 0; - if (fread(s, 1, 9, f) != 9) + if (fread(s, 1, sizeof(s) - 1, f) < 9) + goto quit; + + s[sizeof(s) - 1] = '\0'; + if (!strstr(s, " XPM */")) goto quit; rewind(f); - s[9] = 0; - if (strcmp("/* XPM */", s)) - goto quit; i = 0; j = 0;