commit 878d97068cb6c8ae044332ac3c8218fcad635b42
Author: Bert Münnich <ber.t_AT_posteo.de>
AuthorDate: Thu Oct 20 10:21:55 2016 +0200
Commit: Bert Münnich <ber.t_AT_posteo.de>
CommitDate: Thu Oct 20 10:21:55 2016 +0200
Only open regular files; fixes issue #252
diff --git a/Makefile b/Makefile
index 2339272..c9b140c 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -1,4 +1,4 @@
-VERSION := git-20160928
+VERSION := git-20161020
PREFIX := /usr/local
MANPREFIX := $(PREFIX)/share/man
diff --git a/image.c b/image.c
index ebd522d..801bbe5 100644
--- a/image.c
+++ b/image.c
_AT_@ -19,6 +19,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
_AT_@ -296,8 +297,10 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
bool img_load(img_t *img, const fileinfo_t *file)
{
const char *fmt;
+ struct stat st;
- if (access(file->path, R_OK) < 0 ||
+ if (access(file->path, R_OK) == -1 ||
+ stat(file->path, &st) == -1 || !S_ISREG(st.st_mode) ||
(img->im = imlib_load_image(file->path)) == NULL)
{
if (file->flags & FF_WARN)
diff --git a/thumbs.c b/thumbs.c
index 3988bd2..43bb50c 100644
--- a/thumbs.c
+++ b/thumbs.c
_AT_@ -239,6 +239,7 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
float zw, zh;
thumb_t *t;
fileinfo_t *file;
+ struct stat st;
Imlib_Image im = NULL;
if (n < 0 || n >= *tns->cnt)
_AT_@ -330,12 +331,15 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
}
}
- if (im == NULL && (access(file->path, R_OK) < 0 ||
- (im = imlib_load_image(file->path)) == NULL))
- {
- if (file->flags & FF_WARN)
- error(0, 0, "%s: Error opening image", file->name);
- return false;
+ if (im == NULL) {
+ if (access(file->path, R_OK) == -1 ||
+ stat(file->path, &st) == -1 || !S_ISREG(st.st_mode) ||
+ (im = imlib_load_image(file->path)) == NULL)
+ {
+ if (file->flags & FF_WARN)
+ error(0, 0, "%s: Error opening image", file->name);
+ return false;
+ }
}
imlib_context_set_image(im);
Received on Thu Oct 20 2016 - 10:21:58 CEST
This archive was generated by hypermail 2.3.0
: Thu Oct 20 2016 - 10:24:15 CEST