From 82102826fff82d1c951deec73178c077c7fe713b Mon Sep 17 00:00:00 2001 From: Phillip Berndt Date: Wed, 15 Nov 2017 16:07:19 +0100 Subject: [PATCH] Fix processing of dangling symlinks in the file buffer Since this leads to crashes, release as a patch release. --- README.markdown | 3 +++ lib/filebuffer.c | 9 ++++++++- pqiv.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index e73cfcd..d166f5e 100644 --- a/README.markdown +++ b/README.markdown @@ -170,6 +170,9 @@ For some advanced uses of pqiv, take a look at these resouces: Changelog --------- +pqiv 2.10.1 + * Fix processing of dangling symlinks in the file buffer + pqiv 2.10 * Enable cursor auto-hide by default * Enable mouse navigation in montage mode diff --git a/lib/filebuffer.c b/lib/filebuffer.c index 3a6449c..9216eb6 100644 --- a/lib/filebuffer.c +++ b/lib/filebuffer.c @@ -16,6 +16,7 @@ * */ #include "filebuffer.h" +#include #include #include #include @@ -97,9 +98,15 @@ GBytes *buffered_file_as_bytes(file_t *file, GInputStream *data, GError **error_ int fd = open(input_file_abspath, O_RDONLY); g_free(input_file_abspath); + if(fd < 0) { + g_object_unref(input_file); + g_rec_mutex_unlock(&file_buffer_table_mutex); + *error_pointer = g_error_new(g_quark_from_static_string("pqiv-filebuffer-error"), 1, "Opening the file failed with errno=%d: %s", errno, strerror(errno)); + return NULL; + } void *input_file_data = mmap(NULL, input_file_size, PROT_READ, MAP_SHARED, fd, 0); - if(input_file_data) { + if(input_file_data != MAP_FAILED) { struct buffered_file_mmap_info *mmap_info = g_slice_new(struct buffered_file_mmap_info); mmap_info->ptr = input_file_data; mmap_info->fd = fd; diff --git a/pqiv.h b/pqiv.h index 7fbed73..c2c3ce8 100644 --- a/pqiv.h +++ b/pqiv.h @@ -29,7 +29,7 @@ #include "lib/bostree.h" #ifndef PQIV_VERSION -#define PQIV_VERSION "2.10" +#define PQIV_VERSION "2.10.1" #endif #define FILE_FLAGS_ANIMATION (guint)(1)