From 7a6d9c2f727acadad60e1592099e847d3aba21fd Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sun, 17 Dec 2023 18:54:20 +0700 Subject: [PATCH] mgcp: correctly put NUL character in mgcp_msg_terminate_nul() As was pointed out during code review of a previously merged patch, whenever we write something to the tailroom, we must use msgb_put(). Change-Id: Ibe1605631a94088bfd1f603f7043322ed5585ffe --- include/osmocom/mgcp/mgcp_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/osmocom/mgcp/mgcp_common.h b/include/osmocom/mgcp/mgcp_common.h index be5a0d606..05ae95f3f 100644 --- a/include/osmocom/mgcp/mgcp_common.h +++ b/include/osmocom/mgcp/mgcp_common.h @@ -72,7 +72,7 @@ static inline int mgcp_msg_terminate_nul(struct msgb *msg) if (tail[-1] == '\0') /* nothing to do */; else if (msgb_tailroom(msg) > 0) - tail[0] = '\0'; + msgb_put_u8(msg, (uint8_t)'\0'); else if (tail[-1] == '\r' || tail[-1] == '\n') tail[-1] = '\0'; else {