* will break assumptions about CUI. We know
* this, but Coverity doesn't.
*/
- if (da->type != PW_TYPE_STRING) return -1;
+ if (da->type != PW_TYPE_OCTETS) return -1;
#endif
- data = (uint8_t const *) "";
- datalen = 1;
+ data = NULL;
+ datalen = 0;
goto alloc_cui; /* skip everything */
}
*
* @param[in,out] vp to update
* @param[in] src data to copy
- * @param[in] size of the data
+ * @param[in] size of the data, may be 0 in which case previous value will be freed.
*/
void pairmemcpy(VALUE_PAIR *vp, uint8_t const *src, size_t size)
{
- uint8_t *p, *q;
+ uint8_t *p = NULL, *q;
VERIFY_VP(vp);
- p = talloc_memdup(vp, src, size);
- if (!p) return;
- talloc_set_type(p, uint8_t);
+ if (size > 0) {
+ p = talloc_memdup(vp, src, size);
+ if (!p) return;
+ talloc_set_type(p, uint8_t);
+ }
memcpy(&q, &vp->vp_octets, sizeof(q));
- talloc_free(q);
+ TALLOC_FREE(q);
vp->vp_octets = p;
vp->length = size;
- pairtypeset(vp);
+
+ if (size > 0) pairtypeset(vp);
}
/** Reparent an allocated octet buffer to a VALUE_PAIR
# except for CUI. Thank you, WiMAX!
decode 59 02
-data Chargeable-User-Identity = ''
+data Chargeable-User-Identity = 0x
# Hah! Thought you had it figured out, didn't you?
encode -