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.
diff --git a/openbsc/src/libmsc/mncc_sock.c b/openbsc/src/libmsc/mncc_sock.c
index 5ef9922..d8caf07 100644
--- a/openbsc/src/libmsc/mncc_sock.c
+++ b/openbsc/src/libmsc/mncc_sock.c
@@ -165,6 +165,13 @@
 
 		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 @@
 			}
 			goto close;
 		}
+
+dontsend:
 		/* _after_ we send it, we can deueue */
 		msg2 = msgb_dequeue(&net->upqueue);
 		assert(msg == msg2);