From: Alan T. DeKok Date: Sat, 9 Sep 2023 20:58:16 +0000 (-0400) Subject: try to quiet static analyzers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26f080d35f2204e5662ba1572c54690d7bdbdc82;p=thirdparty%2Ffreeradius-server.git try to quiet static analyzers --- diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index f4dc781891c..30c52345e42 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -392,10 +392,10 @@ fr_dict_attr_t *fr_dict_unknown_attr_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t c fr_slen_t fr_dict_unknown_afrom_oid_substr(TALLOC_CTX *ctx, - fr_dict_attr_t **out, + fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in) - CC_HINT(nonnull); + CC_HINT(nonnull(2,3,4)); int fr_dict_attr_unknown_parent_to_known(fr_dict_attr_t *da, fr_dict_attr_t const *parent); diff --git a/src/lib/util/dict_unknown.c b/src/lib/util/dict_unknown.c index d91e6531ec5..fcf82f76ebe 100644 --- a/src/lib/util/dict_unknown.c +++ b/src/lib/util/dict_unknown.c @@ -391,7 +391,7 @@ fr_dict_attr_t *fr_dict_unknown_attr_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t co * - <= 0 on failure. Negative offset indicates parse error position. */ fr_slen_t fr_dict_unknown_afrom_oid_substr(TALLOC_CTX *ctx, - fr_dict_attr_t **out, + fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in) { diff --git a/src/lib/util/pair_legacy.c b/src/lib/util/pair_legacy.c index 95b291c6407..5dc179ed33c 100644 --- a/src/lib/util/pair_legacy.c +++ b/src/lib/util/pair_legacy.c @@ -115,7 +115,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * ssize_t slen; fr_token_t op; fr_dict_attr_t const *da, *my_parent; - fr_dict_attr_t *da_unknown = NULL; + fr_dict_attr_t const *da_unknown = NULL; fr_dict_attr_err_t err; fr_skip_whitespace(p); @@ -225,6 +225,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * fr_strerror_printf("Unknown attribute \"%.*s\" for parent \"%s\"", (int) (q - ((uint8_t const *) p)), p, my_parent->name); } error: + fr_dict_unknown_free(&da_unknown); *token = T_INVALID; return -(p - buffer); } @@ -239,6 +240,10 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * } do_next: +#ifdef STATIC_ANALYZER + if (!da) goto error; +#endif + next = p + slen; rhs[0] = '\0'; @@ -252,7 +257,6 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * */ op = gettoken(&p, rhs, sizeof(rhs), false); if ((op < T_EQSTART) || (op > T_EQEND)) { - fr_dict_unknown_free(&da); fr_strerror_const("Expecting operator"); goto error; } @@ -285,6 +289,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const * if (fr_pair_append_by_da_parent(my_ctx, &vp, my_list, da) < 0) goto error; } +// fr_dict_unknown_free(&da_unknown); vp->op = op; /*