summaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2016-10-20 10:21:55 +0200
committerBert Münnich <ber.t@posteo.de>2016-10-20 10:21:55 +0200
commit878d97068cb6c8ae044332ac3c8218fcad635b42 (patch)
tree1282bbed9d2743baafd23d9aad8ec02d2d9d7ca7 /image.c
parent891f389f0e228759b05dadec9dafdea5dc772f70 (diff)
downloadnsxiv-878d97068cb6c8ae044332ac3c8218fcad635b42.tar.zst
Only open regular files; fixes issue #252
Diffstat (limited to 'image.c')
-rw-r--r--image.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/image.c b/image.c
index ebd522d..801bbe5 100644
--- a/image.c
+++ b/image.c
@@ -19,6 +19,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -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)