aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2011-08-11 04:37:17 +0200
committerHarald Welte <laforge@gnumonks.org>2011-08-11 17:21:24 +0200
commit46f799b224744979294e5f94f225bb1a720e5063 (patch)
tree71009a723e180669b00096b4154d42b6c9a57429
parente8bd9e885dc50f671d2c4af4267b56c84bf7bb6d (diff)
MNCC: Never send zero-length msgb packets to the socket
This will cause the remote end to read 0 bytes, which is interpreted as if we cleanly closed the socket, making the remote end close their side of the socket, which would lead to us closing our side of the socket, so we should never send such a packet.
-rw-r--r--openbsc/src/libmsc/mncc_sock.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/openbsc/src/libmsc/mncc_sock.c b/openbsc/src/libmsc/mncc_sock.c
index 5ef9922d2..d8caf0754 100644
--- a/openbsc/src/libmsc/mncc_sock.c
+++ b/openbsc/src/libmsc/mncc_sock.c
@@ -165,6 +165,13 @@ static int mncc_sock_write(struct osmo_fd *bfd)
bfd->when &= ~BSC_FD_WRITE;
+ /* bug hunter 8-): maybe someone forgot msgb_put(...) ? */
+ if (!msgb_length(msg)) {
+ LOGP(DMNCC, LOGL_ERROR, "message type (%d) with ZERO "
+ "bytes!\n", mncc_prim->msg_type);
+ goto dontsend;
+ }
+
/* try to send it over the socket */
rc = write(bfd->fd, msgb_data(msg), msgb_length(msg));
if (rc == 0)
@@ -176,6 +183,8 @@ static int mncc_sock_write(struct osmo_fd *bfd)
}
goto close;
}
+
+dontsend:
/* _after_ we send it, we can deueue */
msg2 = msgb_dequeue(&net->upqueue);
assert(msg == msg2);