From 544722f8e01a6408db00aecdcec4d842e481b7e2 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 21 May 2023 00:12:42 +0200 Subject: Try not to thumbnail FIFOs Unless there is a writer, this may block forever. And if there is one, we're somewhat likely to break something. --- fiv-thumbnail.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c index 0933951..0f6d264 100644 --- a/fiv-thumbnail.c +++ b/fiv-thumbnail.c @@ -483,6 +483,7 @@ fiv_thumbnail_produce_for_search( static cairo_surface_t * produce_fallback(GFile *target, FivThumbnailSize size, GError **error) { + // Note that this comes with a TOCTTOU problem. goffset filesize = 0; GFileInfo *info = g_file_query_info(target, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_SIZE, @@ -533,6 +534,13 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error) return NULL; } + // TODO(p): Use open(O_RDONLY | O_NONBLOCK | _O_BINARY), fstat(), + // g_mapped_file_new_from_fd(), and reset the non-blocking flag on the file. + if (!S_ISREG(st.st_mode)) { + set_error(error, "not a regular file"); + return NULL; + } + GError *e = NULL; GMappedFile *mf = g_mapped_file_new(path, FALSE, &e); if (!mf) { -- cgit v1.2.3-70-g09d2