Skip to content

Commit

Permalink
Issue #1689: create unique temporary file with g_file_open_tmp().
Browse files Browse the repository at this point in the history
Not sure this is really solving the issue reported, which is that
`g_get_tmp_dir()` uses environment variables (yet as g_file_open_tmp()
uses g_get_tmp_dir()…). But at least g_file_open_tmp() should create
unique temporary files, which prevents overriding existing files (which
is most likely the only real attack possible here, or at least the only
one I can think of unless some weird vulnerabilities exist in glib).
  • Loading branch information
Jehan committed Jun 24, 2018
1 parent b87d34b commit c21eff4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/tests/test-xcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ gimp_write_and_read_file (Gimp *gimp,
GimpImage *image;
GimpImage *loaded_image;
GimpPlugInProcedure *proc;
gchar *filename;
gchar *filename = NULL;
gint file_handle;
GFile *file;

/* Create the image */
Expand All @@ -311,7 +312,9 @@ gimp_write_and_read_file (Gimp *gimp,
use_gimp_2_8_features);

/* Write to file */
filename = g_build_filename (g_get_tmp_dir (), "gimp-test.xcf", NULL);
file_handle = g_file_open_tmp ("gimp-test-XXXXXX.xcf", &filename, NULL);
g_assert (file_handle != -1);
close (file_handle);
file = g_file_new_for_path (filename);
g_free (filename);

Expand Down

2 comments on commit c21eff4

@msmeissn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CVE-2018-12713 was assigned to this issue.

Is this not just a test app? or is this part of the main gimp program?

@Jehan
Copy link
Collaborator

@Jehan Jehan commented on c21eff4 Jun 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this is just a unit test run when a dev/packager/other runs make check on the source code. This is not part of GIMP at all and nothing is installed with this code.
I added a comment there to clarify: https://gitlab.gnome.org/GNOME/gimp/issues/1689#note_254032

I didn't know that a CVE had been opened for this. Thanks.

Please sign in to comment.