aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-14 11:11:27 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-06-20 14:32:51 +0200
commit8185a941f8d47647de3941e1a9e2b445ca92c2ce (patch)
tree3632ab2c617df2728f8b7b4f6a5f785ba021e589 /openbsc/src
parent51d2a33542064e8605302a22214f57f7886c703e (diff)
mgcp: fix line-break problem in log
When the mgcp_client prints MGCP strings in the log text, it does not remove the line break before printing. This will mess up the log text. This patch removes the line break characters before printing properly.
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/libmgcp/mgcpgw_client.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/openbsc/src/libmgcp/mgcpgw_client.c b/openbsc/src/libmgcp/mgcpgw_client.c
index 12880dd4f..f21983ed6 100644
--- a/openbsc/src/libmgcp/mgcpgw_client.c
+++ b/openbsc/src/libmgcp/mgcpgw_client.c
@@ -304,9 +304,16 @@ static int mgcp_do_write(struct osmo_fd *fd, struct msgb *msg)
{
int ret;
static char strbuf[4096];
- unsigned int l = msg->len < sizeof(strbuf)-1 ? msg->len : sizeof(strbuf)-1;
+ unsigned int l = msg->len < sizeof(strbuf) ? msg->len : sizeof(strbuf);
+ unsigned int i;
+
strncpy(strbuf, (const char*)msg->data, l);
- strbuf[l] = '\0';
+ for (i = 0; i < sizeof(strbuf); i++) {
+ if (strbuf[i] == '\n' || strbuf[i] == '\r') {
+ strbuf[i] = '\0';
+ break;
+ }
+ }
DEBUGP(DMGCP, "Tx MGCP msg to MGCP GW: '%s'\n", strbuf);
LOGP(DMGCP, LOGL_DEBUG, "Sending msg to MGCP GW size: %u\n", msg->len);