pcu_sock: Discard messages that are too short

The downstream code of pcu_sock.c doesn't contain any length checks,
so let's discard any messages that are shorter than the primitive
length.

Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
This commit is contained in:
Harald Welte 2018-02-28 18:13:10 +01:00
parent e1ff92b8dd
commit 70a0ee56f7
1 changed files with 6 additions and 0 deletions

View File

@ -749,6 +749,12 @@ static int pcu_sock_read(struct osmo_fd *bfd)
goto close;
}
if (rc < sizeof(*pcu_prim)) {
LOGP(DPCU, LOGL_ERROR, "Received %d bytes on PCU Socket, but primitive size "
"is %lu, discarding\n", rc, sizeof(*pcu_prim));
return 0;
}
rc = pcu_rx(state->net, pcu_prim->msg_type, pcu_prim);
/* as we always synchronously process the message in pcu_rx() and