projects
/
moonshot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f8bd418
)
allow unknown attributes to be binary or string
author
Luke Howard
<lukeh@padl.com>
Tue, 29 Mar 2011 15:41:15 +0000
(
02:41
+1100)
committer
Luke Howard
<lukeh@padl.com>
Tue, 29 Mar 2011 15:41:15 +0000
(
02:41
+1100)
mech_eap/util_radius.cpp
patch
|
blob
|
history
diff --git
a/mech_eap/util_radius.cpp
b/mech_eap/util_radius.cpp
index
dbd5056
..
288c803
100644
(file)
--- a/
mech_eap/util_radius.cpp
+++ b/
mech_eap/util_radius.cpp
@@
-670,7
+670,8
@@
jsonToAvp(VALUE_PAIR **pVp, JSONObject &obj)
if (da != NULL) {
vp = pairalloc(da);
} else {
if (da != NULL) {
vp = pairalloc(da);
} else {
- vp = paircreate(attrid, PW_TYPE_STRING);
+ /* Assume unknown attributes are octet strings */
+ vp = paircreate(attrid, PW_TYPE_OCTETS);
}
if (vp == NULL) {
throw new std::bad_alloc;
}
if (vp == NULL) {
throw new std::bad_alloc;
@@
-713,12
+714,22
@@
jsonToAvp(VALUE_PAIR **pVp, JSONObject &obj)
if (len >= BASE64_EXPAND(MAX_STRING_LEN))
goto fail;
if (len >= BASE64_EXPAND(MAX_STRING_LEN))
goto fail;
+ /*
+ * If the attribute is unknown, we don't know its syntax; assume
+ * it is an octet string and, if that fails to decode, a string.
+ */
len = base64Decode(str, vp->vp_octets);
len = base64Decode(str, vp->vp_octets);
- if (len < 0)
- goto fail;
-
- vp->length = len;
- vp->vp_octets[len] = '\0';
+ if (len < 0) {
+ if (da == NULL) {
+ assert(len < MAX_STRING_LEN);
+ vp->length = len;
+ memcpy(vp->vp_strvalue, str, len + 1);
+ } else
+ goto fail;
+ } else {
+ vp->length = len;
+ vp->vp_octets[len] = '\0';
+ }
break;
}
}
break;
}
}