1 From adfa0c8f9fec1faac4bea6a94d947ea32e585923 Mon Sep 17 00:00:00 2001
2 From: Christopher Larson <chris_larson@mentor.com>
3 Date: Tue, 13 Dec 2016 20:39:51 -0700
4 Subject: [PATCH] gnome-desktop-thumbnail: don't convert time_t to long
6 Explicitly use strftime+strptime rather than snprintf+atol. This fixes the
7 build for X32, where long's size doesn't match that of time_t.
9 Upstream-Status: Pending
10 Signed-off-by: Christopher Larson <chris_larson@mentor.com>
12 libgnome-desktop/gnome-desktop-thumbnail.c | 16 ++++++++++++++--
13 1 file changed, 14 insertions(+), 2 deletions(-)
15 diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c
16 index 3946309..b756333 100644
17 --- a/libgnome-desktop/gnome-desktop-thumbnail.c
18 +++ b/libgnome-desktop/gnome-desktop-thumbnail.c
23 +#define _XOPEN_SOURCE
26 #include <sys/types.h>
28 @@ -1483,6 +1485,7 @@ save_thumbnail (GdkPixbuf *pixbuf,
29 char *tmp_path = NULL;
32 + struct tm *tmp_mtime = NULL;
35 const char *width, *height;
36 @@ -1502,7 +1505,11 @@ save_thumbnail (GdkPixbuf *pixbuf,
40 - g_snprintf (mtime_str, 21, "%ld", mtime);
41 + tmp_mtime = localtime (&mtime);
44 + strftime (mtime_str, 21, "%s", tmp_mtime);
46 width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width");
47 height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height");
49 @@ -1695,6 +1702,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf,
51 const char *thumb_uri, *thumb_mtime_str;
53 + struct tm tmp_mtime;
55 thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
57 @@ -1705,7 +1713,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf,
58 thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime");
61 - thumb_mtime = atol (thumb_mtime_str);
62 + if (!strptime (thumb_mtime_str, "%s", &tmp_mtime))
64 + thumb_mtime = mktime (&tmp_mtime);
67 if (mtime != thumb_mtime)