diff mbox series

[OpenWrt-Devel,1/1] libubox: add format string checking to ulog()

Message ID CAKjzzGMjFpe3dVo=hDr+nfmtsgX3od3Us7TDji=31NBzdbtmmw@mail.gmail.com
State Accepted
Headers show
Series [OpenWrt-Devel,1/1] libubox: add format string checking to ulog() | expand

Commit Message

Kristupas Savickas June 6, 2019, 6:43 p.m. UTC
From b659ea5fc6511f9f58f04ca4eb58698aa8386f11 Mon Sep 17 00:00:00 2001
From: Kristupas Savickas <savickas.kristupas@gmail.com>
Date: Thu, 6 Jun 2019 21:28:32 +0300
Subject: [PATCH 1/1] libubox: add format string checking to ulog()
To: openwrt-devel@lists.openwrt.org

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 <savickas.kristupas@gmail.com>
---
ulog.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--
2.21.0

Comments

Petr Štetiar June 10, 2019, 6:52 a.m. UTC | #1
Kristupas Savickas <savickas.kristupas@gmail.com> [2019-06-06 21:43:23]:

Hi,

> From b659ea5fc6511f9f58f04ca4eb58698aa8386f11 Mon Sep 17 00:00:00 2001
> From: Kristupas Savickas <savickas.kristupas@gmail.com>
> Date: Thu, 6 Jun 2019 21:28:32 +0300
> Subject: [PATCH 1/1] libubox: add format string checking to ulog()
> To: openwrt-devel@lists.openwrt.org
> 
> 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.

Applying: libubox: add format string checking to ulog()
fatal: corrupt patch at line 14
Patch failed at 0001 libubox: add format string checking to ulog()

-- ynezz
Kristupas Savickas June 10, 2019, 9:51 a.m. UTC | #2
Hi,

sorry about that, fixed.

From 4464f0ec27aa6c2c96b55d37a5eab090325621c9 Mon Sep 17 00:00:00 2001
From: Kristupas Savickas <kristupas.savickas@gmail.com
Date: Mon, 10 Jun 2019 12:36:50 +0300
Subject: [PATCH] libubox: add format string checking to ulog()
To: ynezz@true.cz
Cc: openwrt-devel@lists.openwrt.org

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 <kristupas.savickas@gmail.com>
---
 ulog.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ulog.h b/ulog.h
index 4818b1a..85702ec 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__)
diff mbox series

Patch

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__)