rilmodem / ofono

7f3955122af8b0349fb7d3f2db8abd754459d146
GNU General Public License v2.0
42 stars 29 forks source link

APN verification doesn't allow APNs with single character before period #263

Open githubmt2015 opened 6 years ago

githubmt2015 commented 6 years ago

This is a simple yet critical bug where an APN such as n.ispsn is marked as invalid. THIS IS THE REASON WHY NO ONE ON SPRINT CAN GET ONTO THEIR APN MANUALLY (without auto configuration via OTA). There are untold many people posting about this core issue on the forums. Here is the incredibly simple solution and it took a while to track down:

The > should be >= in the is_valid_apn method found in: https://github.com/rilmodem/ofono/blob/master/src/common.c

gboolean is_valid_apn(const char *apn) { int i; int last_period = 0;

if (apn[0] == '.')
    return FALSE;

for (i = 0; apn[i] != '\0'; i++) {
    if (g_ascii_isalnum(apn[i]))
        continue;

    if (apn[i] == '-')
        continue;

    if (apn[i] == '.' && (i - last_period) >= 1) {
        last_period = i;
        continue;
    }

    return FALSE;
}

return TRUE;

}

A work around could be to write your own C program duplicating all the functionality of ofono, but I have not yet done this. It may be simpler than editing and recompiling ofono since you would need to set up an entire cross compile environment. (I'm using a Nexus 5 with Ubuntu Touch 16.04 from ubports)

Please HELP!!!

JamiKettunen commented 1 year ago

I hope you got in touch with the core developers over on https://t.me/ubports_devel since reporting this issue; it might make sense to take this to another issue tracker since this repo hasn't been touched since 2017.

JamiKettunen commented 1 year ago

From what I can see though the issue is still present in both the upstream oFono https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/src/common.c?h=2.0#n730 and the SailfishOS fork https://github.com/sailfishos/ofono/blob/1.29%2Bgit7/ofono/src/common.c#L742 so I doubt anything has changed