mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
GLocalFileInfo: don't content-sniff zero-length files
This will prevent attempting to read from some files that appear normal but are really device-like, such as those in /proc and /sys. If we can't stat() the file then don't bother attempting to sniff, either. https://bugzilla.gnome.org/show_bug.cgi?id=708525
This commit is contained in:
parent
8f662e7259
commit
b6fc1df022
@ -1253,7 +1253,10 @@ get_content_type (const char *basename,
|
||||
content_type = g_content_type_guess (basename, NULL, 0, &result_uncertain);
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
if (!fast && result_uncertain && path != NULL)
|
||||
/* Don't sniff zero-length files in order to avoid reading files
|
||||
* that appear normal but are not (eg: files in /proc and /sys)
|
||||
*/
|
||||
if (!fast && result_uncertain && path != NULL && statbuf && statbuf->st_size != 0)
|
||||
{
|
||||
guchar sniff_buffer[4096];
|
||||
gsize sniff_length;
|
||||
|
Loading…
Reference in New Issue
Block a user