From 2b32e9059166a23204fcf01e65a9184b3c39166b Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 21 Jan 2014 13:00:19 +0000 Subject: [PATCH] logd: prevent the buffer from being bigger than the maximum ubus size Signed-off-by: John Crispin --- log/syslog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/log/syslog.c b/log/syslog.c index 4cabb43..d0b528d 100644 --- a/log/syslog.c +++ b/log/syslog.c @@ -30,6 +30,8 @@ #include #include +#include + #include "syslog.h" #define LOG_DEFAULT_SIZE (16 * 1024) @@ -279,6 +281,10 @@ log_init(int _log_size) if (_log_size > 0) log_size = _log_size; + /* reserve 512 bytes for protocol overhead */ + if (log_size > (UBUS_MAX_MSGLEN - 512)) + log_size = UBUS_MAX_MSGLEN - 512; + regcomp(&pat_prio, "^<([0-9]*)>(.*)", REG_EXTENDED); regcomp(&pat_tstamp, "^\[[ 0]*([0-9]*).([0-9]*)] (.*)", REG_EXTENDED); -- 2.25.1