File fix-crash.patch of Package modem-manager-gui

# HG changeset patch
# User Alex <alex@linuxonly.ru>
# 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)) {
# HG changeset patch
# User Alex <alex@linuxonly.ru>
# 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 <alex@linuxonly.ru>
+ *      Copyright 2013-2019 Alex <alex@linuxonly.ru>
  *      
  *      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;
openSUSE Build Service is sponsored by