From: John Crispin Date: Tue, 21 Jan 2014 13:00:19 +0000 (+0000) Subject: logd: prevent the buffer from being bigger than the maximum ubus size X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2b32e9059166a23204fcf01e65a9184b3c39166b;p=oweals%2Fubox.git logd: prevent the buffer from being bigger than the maximum ubus size Signed-off-by: John Crispin --- 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);