|
|
4e6cafa |
# HG changeset patch
|
|
|
4e6cafa |
# User Alex <alex@linuxonly.ru>
|
|
|
4e6cafa |
# Date 1550936745 -10800
|
|
|
4e6cafa |
# Node ID 6710bf86869852bb8a9946b628eff5bc1019b5aa
|
|
|
4e6cafa |
# Parent e8a146d4d2ea8525301670fb48b1accfdde13ac9
|
|
|
4e6cafa |
Fix memory corruption because of wrong strsep() usage (Thanks to Persmule)
|
|
|
4e6cafa |
|
|
|
4e6cafa |
diff --git a/src/modules/mm06.c b/src/modules/mm06.c
|
|
|
4e6cafa |
--- a/src/modules/mm06.c
|
|
|
4e6cafa |
+++ b/src/modules/mm06.c
|
|
|
4e6cafa |
@@ -1552,10 +1552,12 @@
|
|
|
4e6cafa |
GVariantIter *iter;
|
|
|
4e6cafa |
guint32 locationtype;
|
|
|
4e6cafa |
GVariant *locationdata;
|
|
|
4e6cafa |
- gchar *locationstring;
|
|
|
4e6cafa |
gsize strlength;
|
|
|
4e6cafa |
+ gchar **fragments;
|
|
|
4e6cafa |
+ gint i;
|
|
|
4e6cafa |
GError *error;
|
|
|
4e6cafa |
-
|
|
|
4e6cafa |
+ const gint numbases[4] = {10, 10, 16, 16};
|
|
|
4e6cafa |
+
|
|
|
4e6cafa |
if ((mmguicore == NULL) || (device == NULL)) return FALSE;
|
|
|
4e6cafa |
mmguicorelc = (mmguicore_t)mmguicore;
|
|
|
4e6cafa |
|
|
|
4e6cafa |
@@ -1578,14 +1580,17 @@
|
|
|
4e6cafa |
g_variant_get(data, "(a{uv})", &iter);
|
|
|
4e6cafa |
while (g_variant_iter_next(iter, "{uv}", &locationtype, &locationdata)) {
|
|
|
4e6cafa |
if ((locationtype == MODULE_INT_MODEM_LOCATION_CAPABILITY_GSM_LAC_CI) && (locationdata != NULL)) {
|
|
|
4e6cafa |
- //3GPP location
|
|
|
4e6cafa |
+ /*3GPP location*/
|
|
|
4e6cafa |
strlength = 256;
|
|
|
4e6cafa |
- locationstring = g_strdup(g_variant_get_string(locationdata, &strlength));
|
|
|
4e6cafa |
- device->loc3gppdata[0] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
|
|
|
4e6cafa |
- device->loc3gppdata[1] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
|
|
|
4e6cafa |
- device->loc3gppdata[2] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
|
|
|
4e6cafa |
- device->loc3gppdata[3] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
|
|
|
4e6cafa |
- g_free(locationstring);
|
|
|
4e6cafa |
+ fragments = g_strsplit(g_variant_get_string(locationdata, &strlength), ",", 4);
|
|
|
4e6cafa |
+ if (fragments != NULL) {
|
|
|
4e6cafa |
+ i = 0;
|
|
|
4e6cafa |
+ while ((fragments[i] != NULL) && (i < 4)) {
|
|
|
4e6cafa |
+ device->loc3gppdata[i] = (guint)strtoul(fragments[i], NULL, numbases[i]);
|
|
|
4e6cafa |
+ i++;
|
|
|
4e6cafa |
+ }
|
|
|
4e6cafa |
+ g_strfreev(fragments);
|
|
|
4e6cafa |
+ }
|
|
|
4e6cafa |
g_variant_unref(locationdata);
|
|
|
4e6cafa |
g_debug("3GPP location: %u, %u, %4x, %4x", device->loc3gppdata[0], device->loc3gppdata[1], device->loc3gppdata[2], device->loc3gppdata[3]);
|
|
|
4e6cafa |
}
|
|
|
4e6cafa |
diff --git a/src/modules/mm07.c b/src/modules/mm07.c
|
|
|
4e6cafa |
--- a/src/modules/mm07.c
|
|
|
4e6cafa |
+++ b/src/modules/mm07.c
|
|
|
4e6cafa |
@@ -1659,8 +1659,11 @@
|
|
|
4e6cafa |
GVariant *locationdata;
|
|
|
4e6cafa |
gchar *locationstring;
|
|
|
4e6cafa |
gsize strlength;
|
|
|
4e6cafa |
+ gchar **fragments;
|
|
|
4e6cafa |
+ gint i;
|
|
|
4e6cafa |
GError *error;
|
|
|
4e6cafa |
-
|
|
|
4e6cafa |
+ const gint numbases[4] = {10, 10, 16, 16};
|
|
|
4e6cafa |
+
|
|
|
4e6cafa |
if ((mmguicore == NULL) || (device == NULL)) return FALSE;
|
|
|
4e6cafa |
mmguicorelc = (mmguicore_t)mmguicore;
|
|
|
4e6cafa |
|
|
|
4e6cafa |
@@ -1684,12 +1687,15 @@
|
|
|
4e6cafa |
if ((locationtype == MODULE_INT_MODEM_LOCATION_SOURCE_3GPP_LAC_CI) && (locationdata != NULL)) {
|
|
|
4e6cafa |
/*3GPP location*/
|
|
|
4e6cafa |
strlength = 256;
|
|
|
4e6cafa |
- locationstring = g_strdup(g_variant_get_string(locationdata, &strlength));
|
|
|
4e6cafa |
- device->loc3gppdata[0] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
|
|
|
4e6cafa |
- device->loc3gppdata[1] = (guint)strtol(strsep(&locationstring, ","), NULL, 10);
|
|
|
4e6cafa |
- device->loc3gppdata[2] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
|
|
|
4e6cafa |
- device->loc3gppdata[3] = (guint)strtol(strsep(&locationstring, ","), NULL, 16);
|
|
|
4e6cafa |
- g_free(locationstring);
|
|
|
4e6cafa |
+ fragments = g_strsplit(g_variant_get_string(locationdata, &strlength), ",", 4);
|
|
|
4e6cafa |
+ if (fragments != NULL) {
|
|
|
4e6cafa |
+ i = 0;
|
|
|
4e6cafa |
+ while ((fragments[i] != NULL) && (i < 4)) {
|
|
|
4e6cafa |
+ device->loc3gppdata[i] = (guint)strtoul(fragments[i], NULL, numbases[i]);
|
|
|
4e6cafa |
+ i++;
|
|
|
4e6cafa |
+ }
|
|
|
4e6cafa |
+ g_strfreev(fragments);
|
|
|
4e6cafa |
+ }
|
|
|
4e6cafa |
g_variant_unref(locationdata);
|
|
|
4e6cafa |
g_debug("3GPP location: %u, %u, %4x, %4x\n", device->loc3gppdata[0], device->loc3gppdata[1], device->loc3gppdata[2], device->loc3gppdata[3]);
|
|
|
4e6cafa |
} else if ((locationtype == MODULE_INT_MODEM_LOCATION_SOURCE_GPS_RAW) && (locationdata != NULL)) {
|