Closes #1320 create User-name from peer ID correctly
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 28 Oct 2015 02:54:31 +0000 (22:54 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 28 Oct 2015 02:55:34 +0000 (22:55 -0400)
src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c

index 6220bbd..fb957e5 100644 (file)
@@ -279,7 +279,6 @@ static int mod_process(void *arg, eap_handler_t *handler)
        uint8_t exch, *in, *ptr, msk[MSK_EMSK_LEN], emsk[MSK_EMSK_LEN];
        uint8_t peer_confirm[SHA256_DIGEST_LENGTH];
        BIGNUM *x = NULL, *y = NULL;
-       char *p;
 
        if (((eap_ds = handler->eap_ds) == NULL) || !inst) return 0;
 
@@ -426,17 +425,13 @@ static int mod_process(void *arg, eap_handler_t *handler)
                        RDEBUG("pwd unable to create fake request!");
                        return 0;
                }
-               fake->username = pair_make_request("User-Name", NULL, T_OP_EQ);
+               fake->username = fr_pair_afrom_num(fake, PW_USER_NAME, 0);
                if (!fake->username) {
-                       RDEBUG("pwd unanable to create value pair for username!");
+                       RDEBUG("Failed creating pair for peer id");
                        talloc_free(fake);
                        return 0;
                }
-               fake->username->vp_length = session->peer_id_len;
-               fake->username->vp_strvalue = p = talloc_array(fake->username, char, fake->username->vp_length + 1);
-               memcpy(p, session->peer_id, session->peer_id_len);
-               p[fake->username->vp_length] = '\0';
-
+               fr_pair_value_bstrncpy(fake->username, session->peer_id, session->peer_id_len);
                fr_pair_add(&fake->packet->vps, fake->username);
 
                if ((vp = fr_pair_find_by_num(request->config, PW_VIRTUAL_SERVER, 0, TAG_ANY)) != NULL) {