From 4e6cafa3a52f1a01aeac0bed61664415b44b25bf Mon Sep 17 00:00:00 2001 From: Artur Iwicki Date: May 26 2019 08:44:45 +0000 Subject: Add upstream patches for memory corruption issues --- diff --git a/mmgui-6710bf86869852bb8a9946b628eff5bc1019b5aa.diff b/mmgui-6710bf86869852bb8a9946b628eff5bc1019b5aa.diff new file mode 100644 index 0000000..8633f0f --- /dev/null +++ b/mmgui-6710bf86869852bb8a9946b628eff5bc1019b5aa.diff @@ -0,0 +1,88 @@ +# HG changeset patch +# User Alex +# Date 1550936745 -10800 +# Node ID 6710bf86869852bb8a9946b628eff5bc1019b5aa +# Parent e8a146d4d2ea8525301670fb48b1accfdde13ac9 +Fix memory corruption because of wrong strsep() usage (Thanks to Persmule) + +diff --git a/src/modules/mm06.c b/src/modules/mm06.c +--- a/src/modules/mm06.c ++++ b/src/modules/mm06.c +@@ -1552,10 +1552,12 @@ + GVariantIter *iter; + guint32 locationtype; + GVariant *locationdata; +- gchar *locationstring; + gsize strlength; ++ gchar **fragments; ++ gint i; + GError *error; +- ++ const gint numbases[4] = {10, 10, 16, 16}; ++ + if ((mmguicore == NULL) || (device == NULL)) return FALSE; + mmguicorelc = (mmguicore_t)mmguicore; + +@@ -1578,14 +1580,17 @@ + g_variant_get(data, "(a{uv})", &iter); + while (g_variant_iter_next(iter, "{uv}", &locationtype, &locationdata)) { + if ((locationtype == MODULE_INT_MODEM_LOCATION_CAPABILITY_GSM_LAC_CI) && (locationdata != NULL)) { +- //3GPP location ++ /*3GPP location*/ + strlength = 256; +- locationstring = g_strdup(g_variant_get_string(locationdata, &strlength)); +- device->loc3gppdata[0] = (guint)strtol(strsep(&locationstring, ","), NULL, 10); +- device->loc3gppdata[1] = (guint)strtol(strsep(&locationstring, ","), NULL, 10); +- device->loc3gppdata[2] = (guint)strtol(strsep(&locationstring, ","), NULL, 16); +- device->loc3gppdata[3] = (guint)strtol(strsep(&locationstring, ","), NULL, 16); +- g_free(locationstring); ++ fragments = g_strsplit(g_variant_get_string(locationdata, &strlength), ",", 4); ++ if (fragments != NULL) { ++ i = 0; ++ while ((fragments[i] != NULL) && (i < 4)) { ++ device->loc3gppdata[i] = (guint)strtoul(fragments[i], NULL, numbases[i]); ++ i++; ++ } ++ g_strfreev(fragments); ++ } + g_variant_unref(locationdata); + g_debug("3GPP location: %u, %u, %4x, %4x", device->loc3gppdata[0], device->loc3gppdata[1], device->loc3gppdata[2], device->loc3gppdata[3]); + } +diff --git a/src/modules/mm07.c b/src/modules/mm07.c +--- a/src/modules/mm07.c ++++ b/src/modules/mm07.c +@@ -1659,8 +1659,11 @@ + GVariant *locationdata; + gchar *locationstring; + gsize strlength; ++ gchar **fragments; ++ gint i; + GError *error; +- ++ const gint numbases[4] = {10, 10, 16, 16}; ++ + if ((mmguicore == NULL) || (device == NULL)) return FALSE; + mmguicorelc = (mmguicore_t)mmguicore; + +@@ -1684,12 +1687,15 @@ + if ((locationtype == MODULE_INT_MODEM_LOCATION_SOURCE_3GPP_LAC_CI) && (locationdata != NULL)) { + /*3GPP location*/ + strlength = 256; +- locationstring = g_strdup(g_variant_get_string(locationdata, &strlength)); +- device->loc3gppdata[0] = (guint)strtol(strsep(&locationstring, ","), NULL, 10); +- device->loc3gppdata[1] = (guint)strtol(strsep(&locationstring, ","), NULL, 10); +- device->loc3gppdata[2] = (guint)strtol(strsep(&locationstring, ","), NULL, 16); +- device->loc3gppdata[3] = (guint)strtol(strsep(&locationstring, ","), NULL, 16); +- g_free(locationstring); ++ fragments = g_strsplit(g_variant_get_string(locationdata, &strlength), ",", 4); ++ if (fragments != NULL) { ++ i = 0; ++ while ((fragments[i] != NULL) && (i < 4)) { ++ device->loc3gppdata[i] = (guint)strtoul(fragments[i], NULL, numbases[i]); ++ i++; ++ } ++ g_strfreev(fragments); ++ } + g_variant_unref(locationdata); + g_debug("3GPP location: %u, %u, %4x, %4x\n", device->loc3gppdata[0], device->loc3gppdata[1], device->loc3gppdata[2], device->loc3gppdata[3]); + } else if ((locationtype == MODULE_INT_MODEM_LOCATION_SOURCE_GPS_RAW) && (locationdata != NULL)) { diff --git a/mmgui-83553d042443c71be71533b6b91ee10f228d935f.diff b/mmgui-83553d042443c71be71533b6b91ee10f228d935f.diff new file mode 100644 index 0000000..5be6b07 --- /dev/null +++ b/mmgui-83553d042443c71be71533b6b91ee10f228d935f.diff @@ -0,0 +1,52 @@ +# HG changeset patch +# User Alex +# Date 1558782045 -10800 +# Node ID 83553d042443c71be71533b6b91ee10f228d935f +# Parent de113e8953ae708043823578b64882cfc5a45ca2 +Fix segfault in strftime_l() because of timestamps from future + +diff --git a/src/strformat.c b/src/strformat.c +--- a/src/strformat.c ++++ b/src/strformat.c +@@ -1,7 +1,7 @@ + /* + * strformat.c + * +- * Copyright 2013-2014 Alex ++ * Copyright 2013-2019 Alex + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -182,18 +182,22 @@ + + memset(buffer, 0, bufsize); + +- if (delta <= 0.0) { +- if (strftime(buffer, bufsize, _("Today, %T"), ftime) == 0) { +- g_snprintf(buffer, bufsize, _("Unknown")); +- } +- } else if ((delta > 0.0) && (delta < 86400.0)) { +- if (strftime(buffer, bufsize, _("Yesterday, %T"), ftime) == 0) { +- g_snprintf(buffer, bufsize, _("Unknown")); ++ if (ftime != NULL) { ++ if (delta <= 0.0) { ++ if (strftime(buffer, bufsize, _("Today, %T"), ftime) == 0) { ++ g_snprintf(buffer, bufsize, _("Unknown")); ++ } ++ } else if ((delta > 0.0) && (delta < 86400.0)) { ++ if (strftime(buffer, bufsize, _("Yesterday, %T"), ftime) == 0) { ++ g_snprintf(buffer, bufsize, _("Unknown")); ++ } ++ } else { ++ if (strftime(buffer, bufsize, _("%d %B %Y, %T"), ftime) == 0) { ++ g_snprintf(buffer, bufsize, _("Unknown")); ++ } + } + } else { +- if (strftime(buffer, bufsize, _("%d %B %Y, %T"), ftime) == 0) { +- g_snprintf(buffer, bufsize, _("Unknown")); +- } ++ g_snprintf(buffer, bufsize, _("Unknown")); + } + + return buffer; diff --git a/modem-manager-gui.spec b/modem-manager-gui.spec index 2596176..bc4f8cd 100644 --- a/modem-manager-gui.spec +++ b/modem-manager-gui.spec @@ -10,6 +10,11 @@ License: GPLv3 URL: https://linuxonly.ru/page/modem-manager-gui Source0: http://download.tuxfamily.org/gsf/source/modem-manager-gui-%{version}.tar.gz +# Upstream patches for memory corruption issues +# https://bitbucket.org/linuxonly/modem-manager-gui/commits/COMMIT_HASH_GOES_HERE/raw +Patch0: mmgui-6710bf86869852bb8a9946b628eff5bc1019b5aa.diff +Patch1: mmgui-83553d042443c71be71533b6b91ee10f228d935f.diff + %global build_using_meson 0 %global with_ofono 0 @@ -126,6 +131,8 @@ Plugin for %{name} allowing to use ofono as the modem manager. %prep %setup -q +%patch0 -p1 +%patch1 -p1 %build @@ -204,6 +211,7 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop * Sun May 26 2019 Artur Iwicki - 0.0.19.1-3 - Add a macro to control building against ofono (dropped from Fedora) - Use make instead of meson for building +- Add upstream patches for memory corruption issues * Fri Jul 13 2018 Fedora Release Engineering - 0.0.19.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild