From 31a3a4523b178aa0b0902fdadd9795eeda6b4a90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Fri, 7 Jan 2022 12:36:27 +0100
Subject: [PATCH] d/patches: Add patch to fix 32bits demo app crash
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Call to where-am-i on 32bits platform ends up with following error:
*** stack smashing detected ***: terminated

GTimeVal parameters are glong, which depends on the platform, but
timestamp returned by geoclue is guint64 for both seconds and useconds.
Furthermore GTimeVal is marked as deprecated.

As this app only displays time with an accuracy in seconds, we can replace
g_date_time_new_from_timeval_local() by g_date_time_new_from_unix_local().

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 ...-where-am-i-crash-on-32bits-platform.patch | 54 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 55 insertions(+)
 create mode 100644 debian/patches/0007-demo-Fix-where-am-i-crash-on-32bits-platform.patch

diff --git a/debian/patches/0007-demo-Fix-where-am-i-crash-on-32bits-platform.patch b/debian/patches/0007-demo-Fix-where-am-i-crash-on-32bits-platform.patch
new file mode 100644
index 0000000..6175ba9
--- /dev/null
+++ b/debian/patches/0007-demo-Fix-where-am-i-crash-on-32bits-platform.patch
@@ -0,0 +1,54 @@
+From fb3f1b103432d238339d8ae02c533e24133bc85e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
+Date: Fri, 7 Jan 2022 12:28:06 +0100
+Subject: [PATCH] demo: Fix where-am-i crash on 32bits platform
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Call to where-am-i on 32bits platform ends up with following error:
+*** stack smashing detected ***: terminated
+
+GTimeVal parameters are glong, which depends on the platform, but
+timestamp returned by geoclue is guint64 for both seconds and useconds.
+Furthermore GTimeVal is marked as deprecated.
+
+As this app only displays time with an accuracy in seconds, we can replace
+g_date_time_new_from_timeval_local() by g_date_time_new_from_unix_local().
+
+Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
+---
+ demo/where-am-i.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/demo/where-am-i.c b/demo/where-am-i.c
+index 5934161..f8f6a43 100644
+--- a/demo/where-am-i.c
++++ b/demo/where-am-i.c
+@@ -84,7 +84,6 @@ print_location (GClueSimple *simple)
+         GClueLocation *location;
+         gdouble altitude, speed, heading;
+         GVariant *timestamp;
+-        GTimeVal tv = { 0 };
+         const char *desc;
+ 
+         location = gclue_simple_get_location (simple);
+@@ -112,10 +111,11 @@ print_location (GClueSimple *simple)
+         if (timestamp) {
+                 GDateTime *date_time;
+                 gchar *str;
++                guint64 secs;
+ 
+-                g_variant_get (timestamp, "(tt)", &tv.tv_sec, &tv.tv_usec);
++                g_variant_get (timestamp, "(tt)", &secs, NULL);
+ 
+-                date_time = g_date_time_new_from_timeval_local (&tv);
++                date_time = g_date_time_new_from_unix_local (secs);
+                 str = g_date_time_format
+                       (date_time,
+                        "%c (%s seconds since the Epoch)");
+-- 
+2.25.1
+
diff --git a/debian/patches/series b/debian/patches/series
index ec78160..4aaf17a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@
 0004-service-Stop-the-client-for-system-applications-when.patch
 fix-nowifi-query.patch
 0006-client-info-Support-cgroup-v2.patch
+0007-demo-Fix-where-am-i-crash-on-32bits-platform.patch
-- 
GitLab