|
| 1 | +From 92af876f24ff6187b73c4bb489751fc5202a6a23 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Michael Catanzaro < [email protected]> |
| 3 | +Date: Tue, 1 Jul 2025 10:58:07 -0500 |
| 4 | +Subject: [PATCH] gfileutils: fix computation of temporary file name |
| 5 | + |
| 6 | +We need to ensure that the value we use to index into the letters array |
| 7 | +is always positive. |
| 8 | + |
| 9 | +Fixes #3716 |
| 10 | + |
| 11 | +Signed-off-by: Azure Linux Security Servicing Account < [email protected]> |
| 12 | +Upstream-reference: https://gitlab.gnome.org/GNOME/glib/-/commit/61e963284889ddb4544e6f1d5261c16120f6fcc3.patch |
| 13 | +--- |
| 14 | + glib/gfileutils.c | 8 ++++---- |
| 15 | + 1 file changed, 4 insertions(+), 4 deletions(-) |
| 16 | + |
| 17 | +diff --git a/glib/gfileutils.c b/glib/gfileutils.c |
| 18 | +index 0918a65..a46e008 100644 |
| 19 | +--- a/glib/gfileutils.c |
| 20 | ++++ b/glib/gfileutils.c |
| 21 | +@@ -1532,9 +1532,9 @@ get_tmp_file (gchar *tmpl, |
| 22 | + static const char letters[] = |
| 23 | + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| 24 | + static const int NLETTERS = sizeof (letters) - 1; |
| 25 | +- gint64 value; |
| 26 | +- gint64 now_us; |
| 27 | +- static int counter = 0; |
| 28 | ++ guint64 value; |
| 29 | ++ guint64 now_us; |
| 30 | ++ static guint counter = 0; |
| 31 | + |
| 32 | + g_return_val_if_fail (tmpl != NULL, -1); |
| 33 | + |
| 34 | +@@ -1553,7 +1553,7 @@ get_tmp_file (gchar *tmpl, |
| 35 | + |
| 36 | + for (count = 0; count < 100; value += 7777, ++count) |
| 37 | + { |
| 38 | +- gint64 v = value; |
| 39 | ++ guint64 v = value; |
| 40 | + |
| 41 | + /* Fill in the random bits. */ |
| 42 | + XXXXXX[0] = letters[v % NLETTERS]; |
| 43 | +-- |
| 44 | +2.45.4 |
| 45 | + |
0 commit comments