diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2017-12-21 15:37:52 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2017-12-21 15:37:52 +0300 |
commit | 2e06c8c9278ab283907f3bb9d1fa28c5edb5f1e4 (patch) | |
tree | b53906747b538522cd57e1e4471ea1e202f8b8b5 /accel-pppd/radius | |
parent | 017c749648a91571b23824a689f2e3fdfe8c9d7e (diff) | |
download | accel-ppp-2e06c8c9278ab283907f3bb9d1fa28c5edb5f1e4.tar.gz accel-ppp-2e06c8c9278ab283907f3bb9d1fa28c5edb5f1e4.zip |
radius: allocate memory for string attributes
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r-- | accel-pppd/radius/packet.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/accel-pppd/radius/packet.c b/accel-pppd/radius/packet.c index a1fe7549..f507ab2b 100644 --- a/accel-pppd/radius/packet.c +++ b/accel-pppd/radius/packet.c @@ -117,7 +117,7 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr) struct rad_attr_t *attr; struct rad_dict_attr_t *da; struct rad_dict_vendor_t *vendor; - uint8_t *ptr, *endptr; + uint8_t *ptr; int n, id, len, vendor_id; socklen_t addr_len = sizeof(*addr); @@ -134,8 +134,6 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr) goto out_err; } - endptr = ptr + REQ_LENGTH_MAX; - pack->buf = ptr; clock_gettime(CLOCK_MONOTONIC, &pack->tv); @@ -228,12 +226,11 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr) if (!da->array) { switch (da->type) { case ATTR_TYPE_STRING: - if (ptr + len == endptr) { - attr->alloc = 1; - attr->val.string = _malloc(len + 1); - memcpy(attr->val.string, ptr, len); - break; - } + attr->alloc = 1; + attr->val.string = _malloc(len + 1); + memcpy(attr->val.string, ptr, len); + attr->val.string[len] = 0; + break; case ATTR_TYPE_OCTETS: case ATTR_TYPE_ETHER: case ATTR_TYPE_TLV: @@ -269,11 +266,6 @@ int rad_packet_recv(int fd, struct rad_packet_t **p, struct sockaddr_in *addr) n -= 2 + len; } - list_for_each_entry(attr, &pack->attrs, entry) { - if (attr->attr->type == ATTR_TYPE_STRING) - attr->val.string[attr->len] = 0; - } - *p = pack; return 0; |