]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use fr_pair_value_bstrncpy() where appropriate
authorAlan T. DeKok <aland@freeradius.org>
Fri, 27 Nov 2015 15:12:04 +0000 (10:12 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 27 Nov 2015 15:12:21 +0000 (10:12 -0500)
src/modules/rlm_digest/rlm_digest.c
src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c

index 22a29b81c5d1bc8fbb3aa58b7ffb0f069d83ba4e..572e04d72b0876a462d395080ace3137829bddb9 100644 (file)
@@ -108,7 +108,6 @@ static int digest_fix(REQUEST *request)
                int length = i->vp_length;
                int attrlen;
                uint8_t const *p = &i->vp_octets[0];
-               char *q;
                VALUE_PAIR *sub;
 
                /*
@@ -149,10 +148,7 @@ static int digest_fix(REQUEST *request)
                         */
                        sub = radius_pair_create(request->packet, &request->packet->vps,
                                                PW_DIGEST_REALM - 1 + p[0], 0);
-                       sub->vp_length = attrlen - 2;
-                       sub->vp_strvalue = q = talloc_array(sub, char, sub->vp_length + 1);
-                       memcpy(q, p + 2, attrlen - 2);
-                       q[attrlen - 2] = '\0';
+                       fr_pair_value_bstrncpy(sub, p + 2, attrlen - 2);
 
                        if ((rad_debug_lvl > 1) && fr_log_fp) {
                                vp_print(fr_log_fp, sub);
index 454e1e70c411e633c88fb86d7eaafb2e0de57bc1..031eba2a0a57adad8070edd869b68e31e00fa524 100644 (file)
@@ -196,7 +196,6 @@ static int CC_HINT(nonnull) mod_process(void *instance, eap_handler_t *handler)
                 */
        } else if (eap_ds->response->type.length <= 128) {
                int rcode;
-               char *p;
 
                /*
                 *      If there was a User-Password in the request,
@@ -208,11 +207,8 @@ static int CC_HINT(nonnull) mod_process(void *instance, eap_handler_t *handler)
                if (!vp) {
                        return 0;
                }
-               vp->vp_length = eap_ds->response->type.length;
-               vp->vp_strvalue = p = talloc_array(vp, char, vp->vp_length + 1);
-               vp->type = VT_DATA;
-               memcpy(p, eap_ds->response->type.data, vp->vp_length);
-               p[vp->vp_length] = 0;
+
+               fr_pair_value_bstrncpy(vp, eap_ds->response->type.data, eap_ds->response->type.length);
 
                /*
                 *      Add the password to the request, and allow