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.
This commit is contained in:
parent
00110a639a
commit
544722f8e0
|
@ -483,6 +483,7 @@ fiv_thumbnail_produce_for_search(
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
produce_fallback(GFile *target, FivThumbnailSize size, GError **error)
|
produce_fallback(GFile *target, FivThumbnailSize size, GError **error)
|
||||||
{
|
{
|
||||||
|
// Note that this comes with a TOCTTOU problem.
|
||||||
goffset filesize = 0;
|
goffset filesize = 0;
|
||||||
GFileInfo *info = g_file_query_info(target,
|
GFileInfo *info = g_file_query_info(target,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_SIZE,
|
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;
|
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;
|
GError *e = NULL;
|
||||||
GMappedFile *mf = g_mapped_file_new(path, FALSE, &e);
|
GMappedFile *mf = g_mapped_file_new(path, FALSE, &e);
|
||||||
if (!mf) {
|
if (!mf) {
|
||||||
|
|
Loading…
Reference in New Issue