diff options
-rw-r--r-- | src/gsm/lapd_core.c | 7 | ||||
-rw-r--r-- | tests/lapd/lapd_test.c | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 74ffef30..fb79a2f0 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -1731,6 +1731,13 @@ static int lapd_data_req(struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx) struct lapd_datalink *dl = lctx->dl; struct msgb *msg = dp->oph.msg; + if (msgb_l3len(msg) == 0) { + LOGP(DLLAPD, LOGL_ERROR, + "writing an empty message is not possible.\n"); + msgb_free(msg); + return -1; + } + LOGP(DLLAPD, LOGL_INFO, "writing message to send-queue: l3len: %d\n", msgb_l3len(msg)); diff --git a/tests/lapd/lapd_test.c b/tests/lapd/lapd_test.c index 8c6b0df2..c924dbf9 100644 --- a/tests/lapd/lapd_test.c +++ b/tests/lapd/lapd_test.c @@ -99,6 +99,16 @@ static struct msgb *create_mm_id_req(void) return msg; } +static struct msgb *create_empty_msg(void) +{ + struct msgb *msg; + + msg = msgb_from_array(NULL, 0); + ASSERT(msgb_l3len(msg) == 0); + rsl_rll_push_l3(msg, RSL_MT_DATA_REQ, 0, 0, 1); + return msg; +} + static struct msgb *create_dummy_data_req(void) { struct msgb *msg; @@ -284,6 +294,11 @@ static void test_lapdm_polling() rc = lapdm_phsap_dequeue_prim(&bts_to_ms_channel.lapdm_dcch, &pp); ASSERT(rc < 0); + /* check sending an empty L3 message fails */ + rc = lapdm_rslms_recvmsg(create_empty_msg(), &bts_to_ms_channel); + ASSERT(rc == -1); + ASSERT(test_state.ms_read == 2); + /* clean up */ lapdm_channel_exit(&bts_to_ms_channel); lapdm_channel_exit(&ms_to_bts_channel); |