From e3d6ff87371ab90c6dac12959130f35fa786de49 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 6 May 2021 11:59:33 +0200 Subject: [PATCH] Check boundary in every step of parse_rfc5424() Signed-off-by: Joachim Wiberg --- src/syslogd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 4c0aba6..a279a3c 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -898,18 +898,18 @@ parsemsg_rfc5424(const char *from, int pri, char *msg) IF_NOT_NILVALUE(buffer.sd) { buffer.sd = msg; /* SD-ELEMENT. */ - while (*msg == '[') { + while (*msg && *msg == '[') { ++msg; /* SD-ID. */ PARSE_SD_NAME(); /* SD-PARAM. */ - while (*msg == ' ') { + while (*msg && *msg == ' ') { ++msg; /* PARAM-NAME. */ PARSE_SD_NAME(); PARSE_CHAR("STRUCTURED-NAME", '='); PARSE_CHAR("STRUCTURED-NAME", '"'); - while (*msg != '"') { + while (*msg && *msg != '"') { FAIL_IF("STRUCTURED-NAME", *msg == '\0'); if (*msg++ == '\\') {