]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Interworking: Fix SIM/USIM NAI construction
authorJouni Malinen <j@w1.fi>
Sun, 19 Feb 2012 12:24:45 +0000 (14:24 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 19 Feb 2012 12:24:45 +0000 (14:24 +0200)
Commit 9914c96febff964374a863bbd6986ade13a2215a moved sizeof(nai) to a
helper function and broke the determination of maximum buffer length.
Fix this by moving the sizeof() to the functions that define the buffer.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/interworking.c

index 3dbdc069d301e8456e7e11bfc82aa648061ca675..be0e78474bec4eeb7a4c73150df75ca160ead47d 100644 (file)
@@ -507,7 +507,8 @@ static int plmn_id_match(struct wpabuf *anqp, const char *imsi)
 }
 
 
-static int build_root_nai(char *nai, const char *imsi, char prefix)
+static int build_root_nai(char *nai, size_t nai_len, const char *imsi,
+                         char prefix)
 {
        const char *sep, *msin;
        char *end, *pos;
@@ -534,7 +535,7 @@ static int build_root_nai(char *nai, const char *imsi, char prefix)
        msin_len = os_strlen(msin);
 
        pos = nai;
-       end = pos + sizeof(nai);
+       end = nai + nai_len;
        if (prefix)
                *pos++ = prefix;
        os_memcpy(pos, imsi, plmn_len);
@@ -561,7 +562,7 @@ static int build_root_nai(char *nai, const char *imsi, char prefix)
 static int set_root_nai(struct wpa_ssid *ssid, const char *imsi, char prefix)
 {
        char nai[100];
-       if (build_root_nai(nai, imsi, prefix) < 0)
+       if (build_root_nai(nai, sizeof(nai), imsi, prefix) < 0)
                return -1;
        return wpa_config_set_quoted(ssid, "identity", nai);
 }
@@ -949,7 +950,7 @@ static int interworking_home_sp(struct wpa_supplicant *wpa_s,
        for (cred = wpa_s->conf->cred; cred; cred = cred->next) {
 #ifdef INTERWORKING_3GPP
                if (cred->imsi &&
-                   build_root_nai(nai, cred->imsi, 0) == 0) {
+                   build_root_nai(nai, sizeof(nai), cred->imsi, 0) == 0) {
                        realm = os_strchr(nai, '@');
                        if (realm)
                                realm++;