GNOME Bugzilla – Bug 652526
segfault in escape_byte_string() in gio/gfileattribute.c
Last modified: 2012-07-06 01:43:21 UTC
escape_byte_string() in gfileattribute.c calls strlen (str) without verifying that str is not NULL. This leads to segmentation faults in code such as the following example: #include <gio/gio.h> void main () { GFileInfo *info; g_type_init (); info = g_file_info_new (); g_file_info_set_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, NULL); g_file_info_get_attribute_as_string (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET); }
Created attachment 189873 [details] [review] Patch to prevent the segfault
I don't think NULL is a valid bytestring, tbh.
(In reply to comment #2) > I don't think NULL is a valid bytestring, tbh. In that case, the API needs to ensure that a bytestring GFileAttributeValue's value cannot be NULL.
No, it is the responsibility of the caller to pass valid arguments. NULL is not a valid bytestring, unless to documentation explicitly states that you may pass NULL.