diff --git a/src/common.c b/src/common.c index 17d1d58a..ce07b934 100644 --- a/src/common.c +++ b/src/common.c @@ -31,6 +31,7 @@ #include #include "common.h" +#include "gprs-context.h" #include "util.h" struct error_entry { @@ -702,9 +703,15 @@ gboolean is_valid_apn(const char *apn) int i; int last_period = 0; + if (apn == NULL) + return FALSE; + if (apn[0] == '.' || apn[0] == '\0') return FALSE; + if (strlen(apn) > OFONO_GPRS_MAX_APN_LENGTH) + return FALSE; + for (i = 0; apn[i] != '\0'; i++) { if (g_ascii_isalnum(apn[i])) continue; diff --git a/src/gprs.c b/src/gprs.c index 098ba3d4..a4132cc0 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -1027,9 +1027,6 @@ 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 (g_str_equal(apn, ctx->context.apn)) return dbus_message_new_method_return(msg); @@ -2376,9 +2373,6 @@ static void provision_context(const struct ofono_gprs_provision_data *ap, if (ap->name && strlen(ap->name) > MAX_CONTEXT_NAME_LENGTH) return; - if (ap->apn == NULL || strlen(ap->apn) > OFONO_GPRS_MAX_APN_LENGTH) - return; - if (is_valid_apn(ap->apn) == FALSE) return; @@ -3228,9 +3222,6 @@ static gboolean load_context(struct ofono_gprs *gprs, const char *group) if (apn == NULL) goto error; - if (strlen(apn) > OFONO_GPRS_MAX_APN_LENGTH) - goto error; - if (type == OFONO_GPRS_CONTEXT_TYPE_MMS) { msgproxy = g_key_file_get_string(gprs->settings, group, "MessageProxy", NULL); diff --git a/src/lte.c b/src/lte.c index 70e0c18a..9b20749c 100644 --- a/src/lte.c +++ b/src/lte.c @@ -152,9 +152,6 @@ static DBusMessage *lte_set_default_apn(struct ofono_lte *lte, if (lte->pending) return __ofono_error_busy(msg); - if (strlen(apn) > OFONO_GPRS_MAX_APN_LENGTH) - return __ofono_error_invalid_format(msg); - if (g_str_equal(apn, lte->info.apn)) return dbus_message_new_method_return(msg);