]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Make Coverity happy with encode_nas_filter_rule() (CID #1503928) (#4554)
authorJames Jones <jejones3141@gmail.com>
Fri, 10 Jun 2022 01:32:20 +0000 (20:32 -0500)
committerGitHub <noreply@github.com>
Fri, 10 Jun 2022 01:32:20 +0000 (21:32 -0400)
encode_nas_filter_rule() is never passed a cursor for which
fr_dcursor_current() returns NULL, so the check at the top
of the loop can be eliminated. Coverity should see the assertions
and not complain about the FR_DBUFF_IN_BYTES_RETURN().O

src/protocols/radius/encode.c

index 8686942d922a2a9ec342cf905794e8544a0dd5b8..41f319d63d039305d11d5e917b840444da6ebde2 100644 (file)
@@ -1245,6 +1245,9 @@ static ssize_t encode_nas_filter_rule(fr_dbuff_t *dbuff,
 
        FR_PROTO_STACK_PRINT(da_stack, depth);
 
+       fr_assert(vp);
+       fr_assert(vp->da);
+
        fr_dbuff_marker(&hdr, &work_dbuff);
        fr_dbuff_marker(&frag_hdr, &work_dbuff);
        fr_dbuff_advance(&hdr, 1);
@@ -1252,7 +1255,7 @@ static ssize_t encode_nas_filter_rule(fr_dbuff_t *dbuff,
 
        fr_assert(vp->da == attr_nas_filter_rule);
 
-       while (vp) {
+       while (true) {
                size_t data_len = vp->vp_length;
                size_t frag_len;
                char const *p = vp->vp_strvalue;