pri_set_apn is called by ofono_gprs_cid_activated() when attached
using LTE technology.
This patch avoid calling DBUS functions in this case. Without
this patch we have a crash in ofono process in this case.

diff --git a/src/gprs.c b/src/gprs.c
index c5e7709..9c6d282 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1027,14 +1027,28 @@ static DBusMessage *pri_set_apn(struct pri_context 
*ctx, DBusConnection *conn,
 {
        GKeyFile *settings = ctx->gprs->settings;
 
-       if (strlen(apn) > OFONO_GPRS_MAX_APN_LENGTH)
-               return __ofono_error_invalid_format(msg);
+       if (strlen(apn) > OFONO_GPRS_MAX_APN_LENGTH) {
+               if (msg)
+                       return __ofono_error_invalid_format(msg);
 
-       if (g_str_equal(apn, ctx->context.apn))
-               return dbus_message_new_method_return(msg);
+               DBG("APN %s too long", apn);
+               return NULL;
+       }
 
-       if (is_valid_apn(apn) == FALSE)
-               return __ofono_error_invalid_format(msg);
+       if (g_str_equal(apn, ctx->context.apn)) {
+               if (msg)
+                       return dbus_message_new_method_return(msg);
+
+               return NULL;
+       }
+
+       if (is_valid_apn(apn) == FALSE) {
+               if (msg)
+                       return __ofono_error_invalid_format(msg);
+
+               DBG("APN %s invalid", apn);
+               return NULL;
+       }
 
        strcpy(ctx->context.apn, apn);
 
-- 
2.7.4

_______________________________________________
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to