>From b659ea5fc6511f9f58f04ca4eb58698aa8386f11 Mon Sep 17 00:00:00 2001
From: Kristupas Savickas <[email protected]>
Date: Thu, 6 Jun 2019 21:28:32 +0300
Subject: [PATCH 1/1] libubox: add format string checking to ulog()
To: [email protected]

This offers an increased level of security, as the arguments will be
checked for validity against the format string at compile time. The
format attribute is supported by both GCC and Clang, so there shouldn't
be any portability issues.

Signed-off-by: Kristupas Savickas <[email protected]>
---
ulog.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ulog.h b/ulog.h
index 4818b1a..46d3c77 100644
--- a/ulog.h
+++ b/ulog.h
@@ -32,7 +32,8 @@ void ulog_close(void);

void ulog_threshold(int threshold);

-void ulog(int priority, const char *fmt, ...);
+void ulog(int priority, const char *fmt, ...)
+       __attribute__ ((format (printf, 2, 3)));

#define ULOG_INFO(fmt, ...) ulog(LOG_INFO, fmt, ## __VA_ARGS__)
#define ULOG_NOTE(fmt, ...) ulog(LOG_NOTICE, fmt, ## __VA_ARGS__)
--
2.21.0

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to