Skip to content

Commit

Permalink
Merge pull request #1526 from nchaigne/3.1.x-dhcp-hstr
Browse files Browse the repository at this point in the history
[3.1.x] DHCP strings decoding
  • Loading branch information
alandekok committed Feb 5, 2016
2 parents 0dad6a5 + a402e19 commit af9a2ec
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/modules/proto_dhcp/dhcp.c
Expand Up @@ -1129,7 +1129,6 @@ int fr_dhcp_decode(RADIUS_PACKET *packet)
* Decode the header.
*/
for (i = 0; i < 14; i++) {
char *q;

vp = fr_pair_make(packet, NULL, dhcp_header_names[i], NULL, T_OP_EQ);
if (!vp) {
Expand Down Expand Up @@ -1185,11 +1184,17 @@ int fr_dhcp_decode(RADIUS_PACKET *packet)
break;

case PW_TYPE_STRING:
q = talloc_array(vp, char, dhcp_header_sizes[i] + 1);
memcpy(q, p, dhcp_header_sizes[i]);
q[dhcp_header_sizes[i]] = '\0';
fr_pair_value_strsteal(vp, q);

/*
* According to RFC 2131, these are null terminated strings.
* We don't trust everyone to abide by the RFC, though.
*/
if (*p != '\0') {
uint8_t *end;
int len;
end = memchr(p, '\0', dhcp_header_sizes[i]);
len = end ? end - p : dhcp_header_sizes[i];
fr_pair_value_bstrncpy(vp, p, len);
}
if (vp->vp_length == 0) fr_pair_list_free(&vp);
break;

Expand Down

0 comments on commit af9a2ec

Please sign in to comment.