mgcp: reserve once byte for '\0' in mgcp_do_read()

We need to be able to terminate the received string in case it was
not nul-terminated by the sender (see mgcp_msg_terminate_nul()).

Change-Id: Icc878af7f671213bb516af62cb601914d86ff808
Fixes: CID#272990
This commit is contained in:
Vadim Yanitskiy 2023-12-11 21:03:26 +07:00 committed by fixeria
parent a68a863b9d
commit f3715dc0d3
1 changed files with 2 additions and 1 deletions

View File

@ -758,7 +758,8 @@ static int mgcp_do_read(struct osmo_fd *fd)
return -1;
}
ret = read(fd->fd, msg->data, 4096 - 128);
/* msgb_tailroom() is basically (4096 - 128); -1 is for '\0' */
ret = read(fd->fd, msg->data, msgb_tailroom(msg) - 1);
if (ret <= 0) {
LOGPMGW(mgcp, LOGL_ERROR, "Failed to read: %s: %d='%s'\n",
osmo_sock_get_name2(fd->fd), errno, strerror(errno));