Check boundary in every step of parse_rfc5424()

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2021-05-06 11:59:33 +02:00
parent d1f1702277
commit e3d6ff8737

View File

@ -898,18 +898,18 @@ parsemsg_rfc5424(const char *from, int pri, char *msg)
IF_NOT_NILVALUE(buffer.sd) { IF_NOT_NILVALUE(buffer.sd) {
buffer.sd = msg; buffer.sd = msg;
/* SD-ELEMENT. */ /* SD-ELEMENT. */
while (*msg == '[') { while (*msg && *msg == '[') {
++msg; ++msg;
/* SD-ID. */ /* SD-ID. */
PARSE_SD_NAME(); PARSE_SD_NAME();
/* SD-PARAM. */ /* SD-PARAM. */
while (*msg == ' ') { while (*msg && *msg == ' ') {
++msg; ++msg;
/* PARAM-NAME. */ /* PARAM-NAME. */
PARSE_SD_NAME(); PARSE_SD_NAME();
PARSE_CHAR("STRUCTURED-NAME", '='); PARSE_CHAR("STRUCTURED-NAME", '=');
PARSE_CHAR("STRUCTURED-NAME", '"'); PARSE_CHAR("STRUCTURED-NAME", '"');
while (*msg != '"') { while (*msg && *msg != '"') {
FAIL_IF("STRUCTURED-NAME", FAIL_IF("STRUCTURED-NAME",
*msg == '\0'); *msg == '\0');
if (*msg++ == '\\') { if (*msg++ == '\\') {