]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
PVS studio won't know about talloc_array_length... and it's more efficient too
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 May 2017 19:51:46 +0000 (15:51 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 May 2017 19:51:46 +0000 (15:51 -0400)
src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c

index 78a49b196ae56ea2157ee3d49066cb163c058756..3a37bd09d075664156628f56bfbd7ae897a84db6 100644 (file)
@@ -93,7 +93,7 @@ static int eapmschapv2_compose(rlm_eap_mschapv2_t const *inst, eap_session_t *ea
                 *  |                             Server Name...
                 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 */
-               length = MSCHAPV2_HEADER_LEN + MSCHAPV2_CHALLENGE_LEN + strlen(inst->identity);
+               length = MSCHAPV2_HEADER_LEN + MSCHAPV2_CHALLENGE_LEN + (talloc_array_length(inst->identity) - 1);
                eap_round->request->type.data = talloc_array(eap_round->request, uint8_t, length);
 
                /*
@@ -118,7 +118,7 @@ static int eapmschapv2_compose(rlm_eap_mschapv2_t const *inst, eap_session_t *ea
                 */
                memcpy(ptr, reply->vp_octets, reply->vp_length);
 
-               memcpy((ptr + reply->vp_length), inst->identity, strlen(inst->identity));
+               memcpy((ptr + reply->vp_length), inst->identity, (talloc_array_length(inst->identity) - 1));
                break;
 
        case FR_MSCHAP2_SUCCESS: