Permalink
Browse files

FR-GV-207 - avoid zero-length malloc() in data2vp()

  • Loading branch information...
alandekok committed Jul 3, 2017
1 parent ec08b30 commit 26be8a680d2a6830e7be98bee10818dd8b6a426a
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/lib/radius.c
@@ -2444,13 +2444,15 @@ static VALUE_PAIR *data2vp(const RADIUS_PACKET *packet,

case PW_TYPE_TLV:
vp->length = length;
vp->vp_tlv = malloc(length);

vp->vp_tlv = malloc(length ? length : 1);
if (!vp->vp_tlv) {
pairfree(&vp);
fr_strerror_printf("No memory");
return NULL;
}
memcpy(vp->vp_tlv, data, length);

if (length) memcpy(vp->vp_tlv, data, length);
break;

case PW_TYPE_COMBO_IP:

0 comments on commit 26be8a6

Please sign in to comment.