5 Feb
2016
5 Feb
'16
12:32 a.m.
case PW_TYPE_STRING: if (*p != '\0') { uint8_t *end; int len; end = memchr(p, '\0', dhcp_header_sizes[i]); len = end ? end - p : dhcp_header_sizes[i]; q = talloc_array(vp, char, len + 1); memcpy(q, p, len); q[len] = '\0'; fr_pair_value_strsteal(vp, q); } if (vp->vp_length == 0) fr_pair_list_free(&vp);
That should work. Though the check for a vp_length == 0 should really be done before allocating any memory.
Agreed, also use talloc_bstrndup to create the buffer. It does most of what you have above. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2