From: Michael Tremer Date: Sun, 5 Oct 2025 15:02:27 +0000 (+0000) Subject: string: Check format strings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e172f37c9a0aea0cffb263e2d351f0e8f1e40572;p=telemetry.git string: Check format strings Signed-off-by: Michael Tremer --- diff --git a/src/daemon/string.h b/src/daemon/string.h index 46f9b8b..0af03a9 100644 --- a/src/daemon/string.h +++ b/src/daemon/string.h @@ -34,6 +34,10 @@ inline int collecty_string_equals(const char* s1, const char* s2) { #define collecty_string_vformat(s, format, args) \ __collecty_string_vformat(s, sizeof(s), format, args) +static inline int __collecty_string_vformat(char* s, + const size_t length, const char* format, va_list args) + __attribute__((format(printf, 3, 0))); + static inline int __collecty_string_vformat(char* s, const size_t length, const char* format, va_list args) { // Write string to buffer @@ -54,7 +58,12 @@ static inline int __collecty_string_vformat(char* s, #define collecty_string_format(s, format, ...) \ __collecty_string_format(s, sizeof(s), format, __VA_ARGS__) -static inline int __collecty_string_format(char* s, const size_t length, const char* format, ...) { +static inline int __collecty_string_format(char* s, + const size_t length, const char* format, ...) + __attribute__((format(printf, 3, 4))); + +static inline int __collecty_string_format(char* s, + const size_t length, const char* format, ...) { va_list args; int r;