From: James Jones Date: Thu, 28 Sep 2023 16:35:34 +0000 (-0500) Subject: Cast sbuff write calls in fr_vlog_perror() to void (CID #1533664) (#5158) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f877e5a2bc5843cfccee7836d6bcccb8be862f8e;p=thirdparty%2Ffreeradius-server.git Cast sbuff write calls in fr_vlog_perror() to void (CID #1533664) (#5158) 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 --- diff --git a/src/lib/util/log.c b/src/lib/util/log.c index 3b5a33914b6..da79ff50c48 100644 --- a/src/lib/util/log.c +++ b/src/lib/util/log.c @@ -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); }