gnome-desktop: do not free() a static buffer
PATCH 1/1 gnome-desktop: do not free() a static buffer
Do not free() the buffer returned by localtime(). Also, switch to calling localtime_r() which is re-entrant.
--- ...op-thumbnail-don-t-convert-time_t-to-long.patch | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-)
meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +11 -16
@@ -9,12 +9,11 @@ build for X32, where long's size doesn't match that of time_t. Upstream-Status: Pending Signed-off-by: Christopher Larson <[email protected]> ---- - libgnome-desktop/gnome-desktop-thumbnail.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) +Modified to use localtime_r() and not free() a static structure. + +Signed-off-by: Joe Slater <[email protected]> + -diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c -index e56c3d7..5d96bf3 100644 --- a/libgnome-desktop/gnome-desktop-thumbnail.c +++ b/libgnome-desktop/gnome-desktop-thumbnail.c @@ -120,6 +120,8 @@
@@ -30,24 +29,23 @@ index e56c3d7..5d96bf3 100644 char *tmp_path = NULL; int tmp_fd; char mtime_str[21]; -+ struct tm *tmp_mtime = NULL; ++ struct tm tmp_mtime; gboolean ret = FALSE; GError *error = NULL; const char *width, *height; -@@ -1124,7 +1127,11 @@ save_thumbnail (GdkPixbuf *pixbuf, +@@ -1124,7 +1127,10 @@ save_thumbnail (GdkPixbuf *pixbuf, goto out; close (tmp_fd); - g_snprintf (mtime_str, 21, "%" G_GINT64_FORMAT, (gint64) mtime); -+ tmp_mtime = localtime (&mtime); -+ if (!tmp_mtime) ++ if (!localtime_r (&mtime,&tmp_mtime)) + goto out; -+ strftime (mtime_str, 21, "%s", tmp_mtime); -+ free (tmp_mtime); ++ ++ strftime (mtime_str, 21, "%s", &tmp_mtime); width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width"); height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height"); -@@ -1319,6 +1326,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1319,6 +1325,7 @@ gnome_desktop_thumbnail_is_valid (GdkPix { const char *thumb_uri, *thumb_mtime_str; time_t thumb_mtime;
@@ -55,7 +53,7 @@ index e56c3d7..5d96bf3 100644 thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI"); if (g_strcmp0 (uri, thumb_uri) != 0) -@@ -1327,7 +1335,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1327,7 +1334,11 @@ gnome_desktop_thumbnail_is_valid (GdkPix thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime"); if (!thumb_mtime_str) return FALSE;
@@ -68,6 +66,3 @@ index e56c3d7..5d96bf3 100644 if (mtime != thumb_mtime) return FALSE; --- -2.14.1 -
Signature · 1 line
2.7.4
I'm not sure we need this patch anymore, it's been rebased on top of upstream changes but one of those changes were to fix x32 builds:
I believe we can drop this patch to gnome-desktop.
Ross
Quoted 95 lines · Joe Slater
Do not
free()the buffer returned bylocaltime(). Also, switch to callinglocaltime_r()which is re-entrant.Signed-off-by Joe Slater <[email protected]>--- ...op-thumbnail-don-t-convert-time_t-to-long.patch | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-)(quoted diff) +0
-0desktop-thumbnail-don-t-convert-time_t-to-long.patch b/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome- desktop-thumbnail-don-t-convert-time_t-to-long.patch index c1a7d4f..be657a8 100644
--- a/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome- desktop-thumbnail-don-t-convert-time_t-to-long.patch +++ b/meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome- desktop-thumbnail-don-t-convert-time_t-to-long.patch(quoted diff) +0
-0@@ -9,12 +9,11 @@ build for X32, where long's size doesn't match that of
time_t.
Upstream-Status: PendingSigned-off-by Christopher Larson <[email protected]>----
-libgnome-desktop/gnome-desktop-thumbnail.c| 16 ++++++++++++++--
- 1 file changed, 14 insertions(+), 2 deletions(-)meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +4
-1+Modified to use localtime_r() and not free() a static structure. + +Signed-off-by: Joe Slater <[email protected]> + -diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c
b/libgnome-desktop/gnome-desktop-thumbnail.cmeta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +6
-8-index e56c3d7..5d96bf3 100644 --- a/libgnome-desktop/gnome-desktop-thumbnail.c +++ b/libgnome-desktop/gnome-desktop-thumbnail.c @@ -120,6 +120,8 @@@@ -30,24 +29,23 @@ index e56c3d7..5d96bf3 100644 char *tmp_path = NULL; int tmp_fd; char mtime_str[21]; -+ struct tm *tmp_mtime = NULL; ++ struct tm tmp_mtime; gboolean ret = FALSE; GError *error = NULL; const char *width, *height; -@@ -1124,7 +1127,11 @@ save_thumbnail (GdkPixbuf *pixbuf, +@@ -1124,7 +1127,10 @@ save_thumbnail (GdkPixbuf *pixbuf, goto out; close (tmp_fd); - g_snprintf (mtime_str, 21, "%" G_GINT64_FORMAT, (gint64) mtime); -+ tmp_mtime = localtime (&mtime); -+ if (!tmp_mtime) ++ if (!localtime_r (&mtime,&tmp_mtime)) + goto out; -+ strftime (mtime_str, 21, "%s", tmp_mtime); -+ free (tmp_mtime); ++ ++ strftime (mtime_str, 21, "%s", &tmp_mtime); width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width"); height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height"); -@@ -1319,6 +1326,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1319,6 +1325,7 @@ gnome_desktop_thumbnail_is_valid (GdkPix { const char *thumb_uri, *thumb_mtime_str;time_t thumb_mtime;meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +1
-1@@ -55,7 +53,7 @@ index e56c3d7..5d96bf3 100644 thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI"); if (g_strcmp0 (uri, thumb_uri) != 0) -@@ -1327,7 +1335,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1327,7 +1334,11 @@ gnome_desktop_thumbnail_is_valid (GdkPix thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime"); if (!thumb_mtime_str)return FALSE;meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +0
-4@@ -68,6 +66,3 @@ index e56c3d7..5d96bf3 100644 if (mtime != thumb_mtime) return FALSE; --- -2.14.1 - --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
I think you are correct. I took out the patch and built sato for qemux86. Epiphany does not abort after loading a url, which was the problem my patch alterations fixed. I’ll try x86-64 with no patch now.
Joe
From: Burton, Ross [mailto:[email protected]]
Sent: Thursday, March 08, 2018 2:10 AM
To: Slater, Joseph
Cc: OE-core
Subject: Re: [OE-core] [oe-core][PATCH 1/1] gnome-desktop: do not free() a static buffer
I'm not sure we need this patch anymore, it's been rebased on top of upstream changes but one of those changes were to fix x32 builds:
I believe we can drop this patch to gnome-desktop.
Ross
On 8 March 2018 at 01:35, Joe Slater <[email protected]<mailto:[email protected]>> wrote:
Do not free() the buffer returned by localtime(). Also,
switch to calling localtime_r() which is re-entrant.
--- ...op-thumbnail-don-t-convert-time_t-to-long.patch | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-)
meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +11 -16
@@ -9,12 +9,11 @@ build for X32, where long's size doesn't match that of time_t. Upstream-Status: Pending Signed-off-by: Christopher Larson <[email protected]<mailto:[email protected]>> ---- - libgnome-desktop/gnome-desktop-thumbnail.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) +Modified to use localtime_r() and not free() a static structure. + +Signed-off-by: Joe Slater <[email protected]<mailto:[email protected]>> + -diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c -index e56c3d7..5d96bf3 100644 --- a/libgnome-desktop/gnome-desktop-thumbnail.c +++ b/libgnome-desktop/gnome-desktop-thumbnail.c @@ -120,6 +120,8 @@
@@ -30,24 +29,23 @@ index e56c3d7..5d96bf3 100644 char *tmp_path = NULL; int tmp_fd; char mtime_str[21]; -+ struct tm *tmp_mtime = NULL; ++ struct tm tmp_mtime; gboolean ret = FALSE; GError *error = NULL; const char *width, *height; -@@ -1124,7 +1127,11 @@ save_thumbnail (GdkPixbuf *pixbuf, +@@ -1124,7 +1127,10 @@ save_thumbnail (GdkPixbuf *pixbuf, goto out; close (tmp_fd); - g_snprintf (mtime_str, 21, "%" G_GINT64_FORMAT, (gint64) mtime); -+ tmp_mtime = localtime (&mtime); -+ if (!tmp_mtime) ++ if (!localtime_r (&mtime,&tmp_mtime)) + goto out; -+ strftime (mtime_str, 21, "%s", tmp_mtime); -+ free (tmp_mtime); ++ ++ strftime (mtime_str, 21, "%s", &tmp_mtime); width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width"); height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height"); -@@ -1319,6 +1326,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1319,6 +1325,7 @@ gnome_desktop_thumbnail_is_valid (GdkPix { const char *thumb_uri, *thumb_mtime_str; time_t thumb_mtime;
@@ -55,7 +53,7 @@ index e56c3d7..5d96bf3 100644 thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI"); if (g_strcmp0 (uri, thumb_uri) != 0) -@@ -1327,7 +1335,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1327,7 +1334,11 @@ gnome_desktop_thumbnail_is_valid (GdkPix thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime"); if (!thumb_mtime_str) return FALSE;
@@ -68,6 +66,3 @@ index e56c3d7..5d96bf3 100644 if (mtime != thumb_mtime) return FALSE; --- -2.14.1 -
--
2.7.4
--
_______________________________________________
Openembedded-core mailing list [email protected]<mailto:[email protected]>
http://lists.openembedded.org/mailman/listinfo/openembedded-core
In looking at the patch, I think the second part, which eliminates an atol() assignment to a time_t variable is still necessary, at least in theory. So, I would not remove the patch, but would replace it.
Joe
From: Burton, Ross [mailto:[email protected]]
Sent: Thursday, March 08, 2018 2:10 AM
To: Slater, Joseph
Cc: OE-core
Subject: Re: [OE-core] [oe-core][PATCH 1/1] gnome-desktop: do not free() a static buffer
I'm not sure we need this patch anymore, it's been rebased on top of upstream changes but one of those changes were to fix x32 builds:
I believe we can drop this patch to gnome-desktop.
Ross
On 8 March 2018 at 01:35, Joe Slater <[email protected]<mailto:[email protected]>> wrote:
Do not free() the buffer returned by localtime(). Also,
switch to calling localtime_r() which is re-entrant.
--- ...op-thumbnail-don-t-convert-time_t-to-long.patch | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-)
meta/recipes-gnome/gnome-desktop/gnome-desktop/gnome-desktop-thumbnail-don-t-convert-time_t-to-long.patch +11 -16
@@ -9,12 +9,11 @@ build for X32, where long's size doesn't match that of time_t. Upstream-Status: Pending Signed-off-by: Christopher Larson <[email protected]<mailto:[email protected]>> ---- - libgnome-desktop/gnome-desktop-thumbnail.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) +Modified to use localtime_r() and not free() a static structure. + +Signed-off-by: Joe Slater <[email protected]<mailto:[email protected]>> + -diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c -index e56c3d7..5d96bf3 100644 --- a/libgnome-desktop/gnome-desktop-thumbnail.c +++ b/libgnome-desktop/gnome-desktop-thumbnail.c @@ -120,6 +120,8 @@
@@ -30,24 +29,23 @@ index e56c3d7..5d96bf3 100644 char *tmp_path = NULL; int tmp_fd; char mtime_str[21]; -+ struct tm *tmp_mtime = NULL; ++ struct tm tmp_mtime; gboolean ret = FALSE; GError *error = NULL; const char *width, *height; -@@ -1124,7 +1127,11 @@ save_thumbnail (GdkPixbuf *pixbuf, +@@ -1124,7 +1127,10 @@ save_thumbnail (GdkPixbuf *pixbuf, goto out; close (tmp_fd); - g_snprintf (mtime_str, 21, "%" G_GINT64_FORMAT, (gint64) mtime); -+ tmp_mtime = localtime (&mtime); -+ if (!tmp_mtime) ++ if (!localtime_r (&mtime,&tmp_mtime)) + goto out; -+ strftime (mtime_str, 21, "%s", tmp_mtime); -+ free (tmp_mtime); ++ ++ strftime (mtime_str, 21, "%s", &tmp_mtime); width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width"); height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height"); -@@ -1319,6 +1326,7 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1319,6 +1325,7 @@ gnome_desktop_thumbnail_is_valid (GdkPix { const char *thumb_uri, *thumb_mtime_str; time_t thumb_mtime;
@@ -55,7 +53,7 @@ index e56c3d7..5d96bf3 100644 thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI"); if (g_strcmp0 (uri, thumb_uri) != 0) -@@ -1327,7 +1335,11 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, +@@ -1327,7 +1334,11 @@ gnome_desktop_thumbnail_is_valid (GdkPix thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime"); if (!thumb_mtime_str) return FALSE;
@@ -68,6 +66,3 @@ index e56c3d7..5d96bf3 100644 if (mtime != thumb_mtime) return FALSE; --- -2.14.1 -
--
2.7.4
--
_______________________________________________
Openembedded-core mailing list [email protected]<mailto:[email protected]>
http://lists.openembedded.org/mailman/listinfo/openembedded-core