After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760324 - [PATCH] gkeyfile.c: find_file_in_data_dirs fails to return the path if file descriptor 0 is used
[PATCH] gkeyfile.c: find_file_in_data_dirs fails to return the path if file d...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gkeyfile
2.47.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-01-08 14:35 UTC by Stewart Brodie
Modified: 2018-02-02 08:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix to correct file descriptor validity test (506 bytes, patch)
2016-01-08 14:35 UTC, Stewart Brodie
committed Details | Review

Description Stewart Brodie 2016-01-08 14:35:35 UTC
Created attachment 318497 [details] [review]
Proposed fix to correct file descriptor validity test

At the end of find_file_in_data_dirs() in glib/gkeyfile.c:

  if (output_file != NULL && fd > 0)

This check to see whether or not to return the path is faulty, because file descriptor 0 may be 0 validly.  The rest of the code uses an inequality with -1 when checking file handles, so this needs to be:

  if (output_file != NULL && fd != -1)

This problem has existed since at least 2.36.3 and is still present in 2.47.4.
Comment 1 Philip Withnall 2018-02-02 08:19:53 UTC
Review of attachment 318497 [details] [review]:

In all realistic situations, (fd > 0) will hold. Only if you’ve closed stdout/stdin/stderr could (fd == 0). But your patch is valid; thanks for submitting it. I’ll apply it and push to master.
Comment 2 Philip Withnall 2018-02-02 08:21:57 UTC
I added a commit message and pushed to master, thanks.