diff options
author | Denis Kenzior <denkenz@gmail.com> | 2011-12-16 08:02:44 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-12-16 08:02:44 -0600 |
commit | 12456649626fc7759721b1514209beeef025dc44 (patch) | |
tree | 3d91d66d65f5180be60a784433965ec64d111597 /src | |
parent | f0d01bdf3794bdb5a09fc3a6e1057739e5050e72 (diff) | |
download | ofono-12456649626fc7759721b1514209beeef025dc44.tar.bz2 |
network: Guard PNN reading
In a somewhat bizarre case, both PNN and OPL might change, which will
trigger sim_pnn_opl_changed twice. This can have some funny
side-effects, so don't allow this to happen in the first place.
Diffstat (limited to 'src')
-rw-r--r-- | src/network.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/network.c b/src/network.c index cc708a2d..def14337 100644 --- a/src/network.c +++ b/src/network.c @@ -40,8 +40,9 @@ #define SETTINGS_STORE "netreg" #define SETTINGS_GROUP "Settings" -#define NETWORK_REGISTRATION_FLAG_HOME_SHOW_PLMN 0x1 -#define NETWORK_REGISTRATION_FLAG_ROAMING_SHOW_SPN 0x2 +#define NETWORK_REGISTRATION_FLAG_HOME_SHOW_PLMN 0x1 +#define NETWORK_REGISTRATION_FLAG_ROAMING_SHOW_SPN 0x2 +#define NETWORK_REGISTRATION_FLAG_READING_PNN 0x4 enum network_registration_mode { NETWORK_REGISTRATION_MODE_AUTO = 0, @@ -1585,7 +1586,7 @@ static void sim_pnn_read_cb(int ok, int length, int record, goto check; if (length < 3 || record_length < 3 || length < record_length) - return; + goto check; total = length / record_length; @@ -1598,6 +1599,8 @@ static void sim_pnn_read_cb(int ok, int length, int record, return; check: + netreg->flags &= ~NETWORK_REGISTRATION_FLAG_READING_PNN; + /* * If PNN is not present then OPL is not useful, don't * retrieve it. If OPL is not there then PNN[1] will @@ -1972,6 +1975,8 @@ static void sim_pnn_opl_changed(int id, void *userdata) struct ofono_netreg *netreg = userdata; GSList *l; + if (netreg->flags & NETWORK_REGISTRATION_FLAG_READING_PNN) + return; /* * Free references to structures on the netreg->eons list and * update the operator info on D-bus. If EFpnn/EFopl read succeeds, @@ -1984,6 +1989,7 @@ static void sim_pnn_opl_changed(int id, void *userdata) sim_eons_free(netreg->eons); netreg->eons = NULL; + netreg->flags |= NETWORK_REGISTRATION_FLAG_READING_PNN; ofono_sim_read(netreg->sim_context, SIM_EFPNN_FILEID, OFONO_SIM_FILE_STRUCTURE_FIXED, sim_pnn_read_cb, netreg); @@ -2125,6 +2131,7 @@ void ofono_netreg_register(struct ofono_netreg *netreg) netreg_load_settings(netreg); + netreg->flags |= NETWORK_REGISTRATION_FLAG_READING_PNN; ofono_sim_read(netreg->sim_context, SIM_EFPNN_FILEID, OFONO_SIM_FILE_STRUCTURE_FIXED, sim_pnn_read_cb, netreg); |