]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Cast sbuff write calls in fr_vlog_perror() to void (CID #1533664) (#5158)
authorJames Jones <jejones3141@gmail.com>
Thu, 28 Sep 2023 16:35:34 +0000 (11:35 -0500)
committerGitHub <noreply@github.com>
Thu, 28 Sep 2023 16:35:34 +0000 (10:35 -0600)
fr_vlog_perror() returns void, so one can't use FR_SBUFF_FOO_RETURN();
the function must always do something reasonable. The possible
errors are invalid format strings or running out of space, and
here rather than a fixed local buffer, the buffer can grow to 16K.
Errors are printed one at a time rather than accumulating them all
in the buffer, so such an event is highly unlikely. We thus cast
the calls to void.

Co-authored-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org>
src/lib/util/log.c

index 3b5a33914b6a290ecb5bfabf1d57b3482a9fae9a..da79ff50c484188635ebcca6d9b1b415702195e4 100644 (file)
@@ -676,12 +676,9 @@ void fr_vlog_perror(fr_log_t const *log, fr_log_type_t type, char const *file, i
        }
 
        if (error && (fmt || f_rules->first_prefix)) {
-               if (fmt) {
-                       /* coverity[check_return] */
-                       fr_sbuff_in_strcpy(&sbuff, ": ");
-               }
-               /* coverity[check_return] */
-               fr_sbuff_in_strcpy(&sbuff, error);
+               if (fmt) (void) fr_sbuff_in_strcpy(&sbuff, ": ");
+               (void) fr_sbuff_in_strcpy(&sbuff, error);
+               error = fr_sbuff_start(&sbuff);         /* may not be talloced with const */
        }
 
        error = fr_sbuff_start(&sbuff);         /* may not be talloced with const */
@@ -693,8 +690,7 @@ void fr_vlog_perror(fr_log_t const *log, fr_log_type_t type, char const *file, i
 
        fr_sbuff_set_to_start(&sbuff);
        if (f_rules->subsq_prefix) {
-               /* coverity[check_return] */
-               fr_sbuff_in_strcpy(&sbuff, f_rules->subsq_prefix);
+               (void) fr_sbuff_in_strcpy(&sbuff, f_rules->subsq_prefix);
                fr_sbuff_marker(&prefix_m, &sbuff);
        }
 
@@ -704,8 +700,7 @@ void fr_vlog_perror(fr_log_t const *log, fr_log_type_t type, char const *file, i
        while ((error = fr_strerror_pop())) {
                if (f_rules->subsq_prefix) {
                        fr_sbuff_set(&sbuff, &prefix_m);
-                       /* coverity[check_return] */
-                       fr_sbuff_in_strcpy(&sbuff, error);      /* may not be talloced with const */
+                       (void) fr_sbuff_in_strcpy(&sbuff, error);       /* may not be talloced with const */
                        error = fr_sbuff_start(&sbuff);
                }