diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-05-21 00:12:42 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-05-21 23:31:41 +0200 |
commit | 544722f8e01a6408db00aecdcec4d842e481b7e2 (patch) | |
tree | 1b737186ee730eb0cb35d69b502df04f8a2dbccf | |
parent | 00110a639aea03250476a32349fd9093d54b2c46 (diff) | |
download | fiv-544722f8e01a6408db00aecdcec4d842e481b7e2.tar.gz fiv-544722f8e01a6408db00aecdcec4d842e481b7e2.tar.xz fiv-544722f8e01a6408db00aecdcec4d842e481b7e2.zip |
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.
-rw-r--r-- | fiv-thumbnail.c | 8 |
1 files changed, 8 insertions, 0 deletions
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) { |