diff options
author | Alexander Kanavin <alex@linutronix.de> | 2023-08-22 19:57:48 +0200 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2023-08-24 10:11:14 +0100 |
commit | b4d60ba1367f15843577d4363b32fb16847b9582 (patch) | |
tree | 7f0bb8e23a03cc23cbc5df675688193c5365646e | |
parent | 40fb81f0ea50d694a420cea7b914d9226ede6a43 (diff) | |
download | glib-b4d60ba1367f15843577d4363b32fb16847b9582.tar.gz |
glib/gfileutils.c: use 64 bits for value in get_tmp_file()
On 32 bit systems 'long' value will overflow in 2038 and become negative.
As it is used to index into letters array, and % operation preserves signs,
data corruption will then occur.
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
-rw-r--r-- | glib/gfileutils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/glib/gfileutils.c b/glib/gfileutils.c index 4ed8171cc..205e517b6 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -1500,7 +1500,7 @@ get_tmp_file (gchar *tmpl, static const char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static const int NLETTERS = sizeof (letters) - 1; - glong value; + gint64 value; gint64 now_us; static int counter = 0; @@ -1521,7 +1521,7 @@ get_tmp_file (gchar *tmpl, for (count = 0; count < 100; value += 7777, ++count) { - glong v = value; + gint64 v = value; /* Fill in the random bits. */ XXXXXX[0] = letters[v % NLETTERS]; |