]> git.ipfire.org Git - collecty.git/commitdiff
string: Check format strings
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Oct 2025 15:02:27 +0000 (15:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Oct 2025 15:02:27 +0000 (15:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/string.h

index 46f9b8b9878a64a19fa255e5ba4c734c2e70bb03..0af03a9941e06281cf7356e77d937768ea47f822 100644 (file)
@@ -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;