GNOME Bugzilla – Bug 787772
Consistently use g_stat and GStatBuf (instead of "struct stat" and plain "stat")
Last modified: 2018-05-02 19:07:33 UTC
Created attachment 359904 [details] [review]
Replace "stat struct" with "GStatBuf" and "stat" with "g_stat" to fix breakages on Windows
The attached patch replaces "stat struct" with "GStatBuf"  and "stat" with "g_stat" .
While this should be identical on *nix it resolves some serious breakages on Windows:
- Field widths of "struct stat" are not constant on Windows,
If the stat function does not match the stat struct used
it will cause overwrites and undefined behavior
- The Windows stat function needs a properly encoded filename.
However we happily feed it UTF-8 in many places watching
it choke to death. (I'm not sure what the idea was here...)
This patch should solve those issues resulting in application bugs like  (GtkRecentChooser failing for files with non-ASCII characters).
As for gtk3 a previous patch from bug 660730 already fixed most of these. However I still found some remaining occurrences of "struct stat" in the codebase, so if desired I can look into providing a patch for those, too.
It seems worth mentioning that MSYS2 has applied this patch downstream:
Review of attachment 359904 [details] [review]:
@@ +199,3 @@
+search_visit_func (const char *fpath,
+ const GStatBuf *sb,
We're using ftw(), here, so there's really no need to use GStatBuf.
@@ +79,3 @@
+static int check_dir_mtime (const char *dir,
+ const GStatBuf *sb,
Same as above: this is a callback from ftw().
@@ +717,3 @@
+ GStatBuf data_info;
CUPS is not available on Windows, so there's no point in using GStatBuf. The `data_info` variable is used with fstat() later on.
Created attachment 366781 [details] [review]
Replace "stat struct" with "GStatBuf" and "stat" with "g_stat" to fix breakages on Windows v2
Thanks for the review.
Updated patch is attached.
Review of attachment 366781 [details] [review]:
Looks good, now. Thanks!
-- GitLab Migration Automatic Message --
This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/914.