Skip to content

Commit

Permalink
Use memory within value_pair_tmpl_t structs to hold unknown dictionar…
Browse files Browse the repository at this point in the history
…y attributes

This means tmpl_from_attr_str works correctly with both talloced and stack allocated VPT structs
  • Loading branch information
arr2036 committed Sep 27, 2014
1 parent 28194ac commit 2e1df3c
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 130 deletions.
19 changes: 15 additions & 4 deletions src/include/libradius.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ char *vp_aprint(TALLOC_CTX *ctx, VALUE_PAIR const *vp, bool escape);
/*
* Dictionary functions.
*/
#define DICT_VALUE_MAX_NAME_LEN (128)
#define DICT_VENDOR_MAX_NAME_LEN (128)
#define DICT_ATTR_MAX_NAME_LEN (128)

#define DICT_ATTR_SIZE sizeof(DICT_ATTR) + DICT_ATTR_MAX_NAME_LEN

extern const int dict_attr_allowed_chars[256];
int dict_valid_name(char const *name);
int str2argv(char *str, char **argv, int max_argc);
Expand All @@ -453,13 +459,18 @@ int dict_addvalue(char const *namestr, char const *attrstr, int value);
int dict_init(char const *dir, char const *fn);
void dict_free(void);
int dict_read(char const *dir, char const *filename);

void dict_attr_free(DICT_ATTR const **da);
DICT_ATTR const *dict_attrunknown(TALLOC_CTX *ctx, unsigned int attr, unsigned int vendor);
DICT_ATTR const *dict_attrunknownbyname(TALLOC_CTX *ctx, char const *attribute);
DICT_ATTR const *dict_addunknown(DICT_ATTR const *old);
int dict_unknown_from_fields(DICT_ATTR *da, unsigned int attr, unsigned int vendor);
DICT_ATTR const *dict_unknown_afrom_fields(TALLOC_CTX *ctx, unsigned int attr, unsigned int vendor);
int dict_unknown_from_str(DICT_ATTR *da, char const *name);
int dict_unknown_from_substr(DICT_ATTR *da, char const **name);
DICT_ATTR const *dict_unknown_afrom_str(TALLOC_CTX *ctx, char const *name);
DICT_ATTR const *dict_unknown_add(DICT_ATTR const *old);

DICT_ATTR const *dict_attrbyvalue(unsigned int attr, unsigned int vendor);
DICT_ATTR const *dict_attrbyname(char const *attr);
DICT_ATTR const *dict_attrbyname_substr(TALLOC_CTX *ctx, char const **name);
DICT_ATTR const *dict_attrbyname_substr(char const **name);
DICT_ATTR const *dict_attrbytype(unsigned int attr, unsigned int vendor,
PW_TYPE type);
DICT_ATTR const *dict_attrbyparent(DICT_ATTR const *parent, unsigned int attr,
Expand Down
8 changes: 5 additions & 3 deletions src/include/tmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ typedef struct value_pair_tmpl_t {
request_refs_t request; //!< Request to search or insert in.
pair_lists_t list; //!< List to search or insert in.

DICT_ATTR const *da; //!< Resolved dictionary attribute.
int num; //!< for array references
int8_t tag; //!< for tag references
DICT_ATTR const *da; //!< Resolved dictionary attribute.
uint8_t unknown[DICT_ATTR_SIZE]; //!< Unknown dictionary attribute buffer.
int num; //!< for array references
int8_t tag; //!< for tag references.
} attribute;

union {
Expand All @@ -148,6 +149,7 @@ typedef struct value_pair_tmpl_t {
#define tmpl_request attribute.request
#define tmpl_list attribute.list
#define tmpl_da attribute.da
#define tmpl_unknown attribute.unknown
#define tmpl_num attribute.num
#define tmpl_tag attribute.tag

Expand Down
Loading

0 comments on commit 2e1df3c

Please sign in to comment.