]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/blob
c1a7d4f40f577a05d6ff0edef57e34972181b03a
[thirdparty/openembedded/openembedded-core-contrib.git] /
1 From 9048939b76b3bd10783adb79ed0aaf6cd13895cc 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 1/2] gnome-desktop-thumbnail: don't convert time_t to long
5
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.
8
9 Upstream-Status: Pending
10 Signed-off-by: Christopher Larson <chris_larson@mentor.com>
11
12 ---
13 libgnome-desktop/gnome-desktop-thumbnail.c | 16 ++++++++++++++--
14 1 file changed, 14 insertions(+), 2 deletions(-)
15
16 diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c
17 index e56c3d7..5d96bf3 100644
18 --- a/libgnome-desktop/gnome-desktop-thumbnail.c
19 +++ b/libgnome-desktop/gnome-desktop-thumbnail.c
20 @@ -120,6 +120,8 @@
21 * Since: 2.2
22 */
23
24 +#define _XOPEN_SOURCE
25 +
26 #include <config.h>
27
28 #include <glib.h>
29 @@ -1105,6 +1107,7 @@ save_thumbnail (GdkPixbuf *pixbuf,
30 char *tmp_path = NULL;
31 int tmp_fd;
32 char mtime_str[21];
33 + struct tm *tmp_mtime = NULL;
34 gboolean ret = FALSE;
35 GError *error = NULL;
36 const char *width, *height;
37 @@ -1124,7 +1127,11 @@ save_thumbnail (GdkPixbuf *pixbuf,
38 goto out;
39 close (tmp_fd);
40
41 - g_snprintf (mtime_str, 21, "%" G_GINT64_FORMAT, (gint64) mtime);
42 + tmp_mtime = localtime (&mtime);
43 + if (!tmp_mtime)
44 + goto out;
45 + strftime (mtime_str, 21, "%s", tmp_mtime);
46 + free (tmp_mtime);
47 width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width");
48 height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height");
49
50 @@ -1319,6 +1326,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf,
51 {
52 const char *thumb_uri, *thumb_mtime_str;
53 time_t thumb_mtime;
54 + struct tm tmp_mtime;
55
56 thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
57 if (g_strcmp0 (uri, thumb_uri) != 0)
58 @@ -1327,7 +1335,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf,
59 thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime");
60 if (!thumb_mtime_str)
61 return FALSE;
62 - thumb_mtime = atol (thumb_mtime_str);
63 + if (!strptime (thumb_mtime_str, "%s", &tmp_mtime))
64 + return FALSE;
65 + thumb_mtime = mktime (&tmp_mtime);
66 + if (!thumb_mtime)
67 + return FALSE;
68 if (mtime != thumb_mtime)
69 return FALSE;
70
71 --
72 2.14.1
73