aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2024-02-09 14:36:30 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2024-02-23 10:34:23 +0100
commit4f01ae3d6289490e5e77981c72f7e037d9fb941a (patch)
tree86858c161af42c7b32231d8dcd5d46de148b5206
parent00c462cee5efa8c6b42fd598564ba5125b6a71a4 (diff)
osmo_io: Reject writing messages with length of 0
io_uring will reject to transmit messages with length of 0. Change-Id: I94be5ec7344d92157f7853c6c0ddf7007513ba8e Related: OS#5751
-rw-r--r--src/core/osmo_io.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 82d8340d..b0e023ad 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -421,6 +421,11 @@ int osmo_iofd_write_msgb(struct osmo_io_fd *iofd, struct msgb *msg)
{
int rc;
+ if (OSMO_UNLIKELY(msgb_length(msg) == 0)) {
+ LOGPIO(iofd, LOGL_ERROR, "Length is 0, rejecting msgb.\n");
+ return -EINVAL;
+ }
+
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_READ_WRITE);
if (OSMO_UNLIKELY(!iofd->io_ops.write_cb)) {
LOGPIO(iofd, LOGL_ERROR, "write_cb not set, Rejecting msgb\n");
@@ -463,6 +468,11 @@ int osmo_iofd_sendto_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int sendto_
{
int rc;
+ if (OSMO_UNLIKELY(msgb_length(msg) == 0)) {
+ LOGPIO(iofd, LOGL_ERROR, "Length is 0, rejecting msgb.\n");
+ return -EINVAL;
+ }
+
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_RECVFROM_SENDTO);
if (OSMO_UNLIKELY(!iofd->io_ops.sendto_cb)) {
LOGPIO(iofd, LOGL_ERROR, "sendto_cb not set, Rejecting msgb\n");
@@ -511,6 +521,11 @@ int osmo_iofd_sctp_send_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int send
struct cmsghdr *cmsg;
struct sctp_sndrcvinfo *sinfo;
+ if (OSMO_UNLIKELY(msgb_length(msg) == 0)) {
+ LOGPIO(iofd, LOGL_ERROR, "Length is 0, rejecting msgb.\n");
+ return -EINVAL;
+ }
+
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND);
if (OSMO_UNLIKELY(!iofd->io_ops.write_cb)) {
LOGPIO(iofd, LOGL_ERROR, "write_cb not set, Rejecting msgb\n");