]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Annotate intentional writes of const-qualified data (CID #1508484, #1517674) (#4872)
authorJames Jones <jejones3141@gmail.com>
Fri, 31 Mar 2023 22:03:53 +0000 (17:03 -0500)
committerGitHub <noreply@github.com>
Fri, 31 Mar 2023 22:03:53 +0000 (16:03 -0600)
Certain members of fr_value_box_t and hence of fr_pair_t have
const-qualified type, so pair_init_from_da() and fr_value_box_init(),
which modify some of those members, coverity points them out.
(UNCONST() placates the compiler, but not coverity.)

The coverity primitives that one might think would apply here,
__coverity_write_buffer_{bytes, elements}__(), are said to relate
mostly to checkers unrelated to writes to const-qualified fields,
so we annotate.

src/lib/util/pair.c
src/lib/util/value.h

index 93070e1c687c9c36a037a0d325ee83bb6ee74629..91580d5d73e159fe33dffda9831ef33e5d437011 100644 (file)
@@ -190,12 +190,14 @@ static inline CC_HINT(always_inline) void pair_init_from_da(fr_pair_t *vp, fr_di
                 *      Make it very obvious if we failed
                 *      to initialise something.
                 */
+               /* coverity[store_writes_const_field] */
                memset(&vp->data, 0xff, sizeof(vp->data));
 #endif
 
                /*
                 *      Hack around const issues...
                 */
+               /* coverity[store_writes_const_field] */
                memcpy(UNCONST(fr_type_t *, &vp->vp_type), &da->type, sizeof(vp->vp_type));
                fr_pair_list_init(&vp->vp_group);
                vp->vp_group.is_child = true;
index ca06ca54dade1f9a7c038e1787a72dfdad95128b..866b24903bee97aa1ba67237d2ccd688d3fc58b7 100644 (file)
@@ -455,6 +455,7 @@ int         fr_value_box_steal(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_value_box_t *sr
 static inline CC_HINT(nonnull(1), always_inline)
 void fr_value_box_init(fr_value_box_t *vb, fr_type_t type, fr_dict_attr_t const *enumv, bool tainted)
 {
+       /* coverity[store_writes_const_field] */
        memcpy(vb, &(fr_value_box_t){
                        .type = type,
                        .enumv = enumv,