Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.1.x] DHCP strings decoding #1526

Merged
merged 1 commit into from Feb 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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