Skip to content

Commit 4fd84f8

Browse files
committed
ensure that unknown DA's aren't parented from the NULL ctx
1 parent be07beb commit 4fd84f8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/lib/server/tmpl_tokenize.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,8 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
19561956
if (fr_sbuff_out(NULL, &oid, name) > 0) {
19571957
namespace = fr_dict_unlocal(namespace);
19581958

1959+
fr_assert(ar == NULL);
1960+
19591961
fr_strerror_clear(); /* Clear out any existing errors */
19601962

19611963
if (fr_dict_by_da(namespace) == fr_dict_internal()) goto disallow_unknown;
@@ -1981,6 +1983,7 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
19811983
* then we create an unknown attribute with
19821984
* the specified attribute number.
19831985
*/
1986+
MEM(ar = talloc(ctx, tmpl_attr_t));
19841987

19851988
/*
19861989
* VSAs have VENDORs as children. All others are just normal things.
@@ -2000,7 +2003,6 @@ static inline int tmpl_attr_afrom_attr_substr(TALLOC_CTX *ctx, tmpl_attr_error_t
20002003
goto error;
20012004
}
20022005

2003-
MEM(ar = talloc(ctx, tmpl_attr_t));
20042006
*ar = (tmpl_attr_t){
20052007
.ar_num = NUM_UNSPEC,
20062008
.ar_type = TMPL_ATTR_TYPE_UNKNOWN,

src/lib/util/ext.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ void *fr_ext_alloc_size(fr_ext_t const *def, void **chunk_p, int ext, size_t ext
6666
uint8_t *ext_ptr;
6767
char const *type;
6868

69+
fr_assert(chunk != NULL);
70+
fr_assert(talloc_parent(chunk) != NULL);
71+
6972
ext_offsets = fr_ext_offsets(def, *chunk_p);
7073
if (ext_offsets[ext]) return fr_ext_ptr(*chunk_p, ext_offsets[ext], info->has_hdr);
7174

0 commit comments

Comments
 (0)