summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2012-09-20 01:38:40 +0300
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-19 18:00:38 -0700
commitf4bc0ca37b47fd731bf55bc6c4675a34092771da (patch)
tree54f8d37f61dc818301d2e21617ad38911fd482d0
parentd14932058f191de2a812a9b3b9ad87c5febd2b3e (diff)
downloadsubsurface-f4bc0ca37b47fd731bf55bc6c4675a34092771da.tar.gz
Use long instead of int when retrieving DIVE_DATE via gtk_tree_model_get
The type of the DIVE_DATE field is G_TYPE_LONG, so when accessing it we have to pass gtk_tree_model_get() the proper "long *" pointer, rather than an int. On 64-bit platforms, passing a pointer to an int would otherwise result in randomly overwriting another four bytes of stack. Sadly, there are not much safety checks to warn if our passed variable to the vararg list is of the correct type, which is unlike gtk_tree_model_get_value(), which will report typed errors. This solves a bug that may potentially result in undefined behaviour on some x64 OS (e.g Ubuntu 12.04 x64). Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--divelist.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/divelist.c b/divelist.c
index f032e6243..590748691 100644
--- a/divelist.c
+++ b/divelist.c
@@ -378,15 +378,16 @@ static void date_data_func(GtkTreeViewColumn *col,
GtkTreeIter *iter,
gpointer data)
{
- int val, idx, nr;
+ int idx, nr;
+ long date;
struct tm *tm;
time_t when;
char buffer[40];
- gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &val, -1);
+ gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &date, -1);
nr = gtk_tree_model_iter_n_children(model, iter);
/* 2038 problem */
- when = val;
+ when = date;
tm = gmtime(&when);
if (idx < 0) {