Skip to content

Commit

Permalink
Fix processing of dangling symlinks in the file buffer
Browse files Browse the repository at this point in the history
Since this leads to crashes, release as a patch release.
  • Loading branch information
phillipberndt committed Nov 15, 2017
1 parent 7d5f7d5 commit 8210282
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion lib/filebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*/
#include "filebuffer.h"
#include <errno.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gio/gio.h>
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pqiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8210282

Please sign in to comment.