summaryrefslogtreecommitdiff
path: root/accel-pppd/radius
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2014-01-16 21:25:23 +0100
committerDmitry Kozlov <xeb@mail.ru>2014-01-17 15:35:27 +0400
commitfb63e5d509681449e4b2428bc8c023d01895dd9d (patch)
tree8535b208a0deb0518f6e185662885ec692ed45b4 /accel-pppd/radius
parentd0c5faf047fa085795e6881b67bcb6af73b2a90d (diff)
downloadaccel-ppp-fb63e5d509681449e4b2428bc8c023d01895dd9d.tar.gz
accel-ppp-fb63e5d509681449e4b2428bc8c023d01895dd9d.zip
radius: allow creation of zero length attributes
Some attributes, like IWF-Session (RFC 4679), may have no payload. Allow the len parameter of rad_packet_add_octets() to be 0 in order to add such attributes (and do the same for rad_packet_change_octets() for API consistency). Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r--accel-pppd/radius/packet.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/accel-pppd/radius/packet.c b/accel-pppd/radius/packet.c
index 51220672..ace9f6e2 100644
--- a/accel-pppd/radius/packet.c
+++ b/accel-pppd/radius/packet.c
@@ -450,13 +450,17 @@ int __export rad_packet_add_octets(struct rad_packet_t *pack, const char *vendor
ra->vendor = vendor;
ra->attr = attr;
ra->len = len;
- ra->val.octets = _malloc(len);
- if (!ra->val.octets) {
- log_emerg("radius: out of memory\n");
- _free(ra);
- return -1;
+
+ if (len) {
+ ra->val.octets = _malloc(len);
+ if (!ra->val.octets) {
+ log_emerg("radius: out of memory\n");
+ _free(ra);
+ return -1;
+ }
+ memcpy(ra->val.octets, val, len);
}
- memcpy(ra->val.octets, val, len);
+
list_add_tail(&ra->entry, &pack->attrs);
pack->len += (vendor_name ? 8 : 2) + len;
@@ -476,7 +480,7 @@ int __export rad_packet_change_octets(struct rad_packet_t *pack, const char *ven
return -1;
ra->val.octets = _realloc(ra->val.octets, len);
- if (!ra->val.octets) {
+ if (len && !ra->val.octets) {
log_emerg("radius: out of memory\n");
return -1;
}
@@ -485,7 +489,8 @@ int __export rad_packet_change_octets(struct rad_packet_t *pack, const char *ven
ra->len = len;
}
- memcpy(ra->val.octets, val, len);
+ if (len)
+ memcpy(ra->val.octets, val, len);
return 0;
}