From: Alan T. DeKok Date: Tue, 24 Jan 2017 21:59:36 +0000 (-0500) Subject: allow EVS for unknown attributes, too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1baded4defe35d79c74a972347b3efe4aed4d5a;p=thirdparty%2Ffreeradius-server.git allow EVS for unknown attributes, too --- diff --git a/src/lib/dict.c b/src/lib/dict.c index 30197168800..133585c16d2 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -3193,9 +3193,10 @@ int fr_dict_unknown_from_oid(fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict p = q; /* - * The common case: Attr-26. Just create it and go. + * The common case: Attr-X, Just create it and go. */ if (!*p) { +do_create: if (!da) { fr_strerror_printf("Failed creating attribute"); return -1; @@ -3224,6 +3225,7 @@ int fr_dict_unknown_from_oid(fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict */ child = fr_dict_attr_child_by_num(parent, attr); if (!child) { +fail: fr_strerror_printf("Cannot parse names without dictionaries"); return -1; } @@ -3237,10 +3239,44 @@ int fr_dict_unknown_from_oid(fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict return -1; } + /* + * Attr-241.X + * + * X may be 26, in which case we allow unknown vendors under it. + */ + if ((child->type == PW_TYPE_EXTENDED) || (child->type == PW_TYPE_LONG_EXTENDED)) { + parent = child; + + num = strtoul(p + 5, &q, 10); + if (!num || (num >= UINT_MAX)) { + fr_strerror_printf("Invalid value in attribute name '%s'", name); + return -1; + } + + attr = num; + p = q; + + /* + * The common case: Attr-241.X, Just create it and go. + */ + if (!*p) goto do_create; + + /* + * Attr-241.X. Does X exist? + */ + child = fr_dict_attr_child_by_num(parent, attr); + if (!child) goto fail; + + /* + * Fall through to checking for EVS. + */ + } + /* * Attr-26 means that the following data is a 32-bit vendor ID. */ - if (child->type == PW_TYPE_VSA) { + if ((child->type == PW_TYPE_VSA) || + (child->type == PW_TYPE_EVS)) { fr_dict_attr_t const *dv; num = strtoul(p + 1, &q, 10);