]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Account for IV in return value of encode_tlv_hdr
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 Dec 2017 00:46:05 +0000 (00:46 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 Dec 2017 00:46:05 +0000 (00:46 +0000)
src/modules/rlm_eap/lib/sim/encode.c

index 98a10f8af0f99cccf81a26b33eee7800e27599bd..f260098fd1e3f9e88045ebad02cc4f8d9a6aa133 100644 (file)
@@ -882,12 +882,13 @@ static ssize_t encode_tlv_hdr(uint8_t *out, size_t outlen,
         *      length field in the buffer.
         */
        total_len = ROUND_UP_POW2(len + 2, 4);
-       p[0] = da->attr & 0xff;                 /* Type */
-       p[1] = total_len >> 2;          /* Length */
+       *p++ = da->attr & 0xff;                 /* Type */
+       *p++ = total_len >> 2;                  /* Length */
+       p += len;                               /* Now increment */
 
-       FR_PROTO_HEX_DUMP("Done TLV attribute", out, total_len);
+       FR_PROTO_HEX_DUMP("Done TLV attribute", out, p - out);
 
-       return total_len;       /* AT_IV + AT_*(TLV) */
+       return p - out; /* AT_IV + AT_*(TLV) - Can't use total_len, doesn't include IV */
 }
 
 ssize_t fr_sim_encode_pair(uint8_t *out, size_t outlen, vp_cursor_t *cursor, void *encoder_ctx)