laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmocore/+/35912?usp=email )
(
7 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: osmo_io: Reject writing messages with length of 0
......................................................................
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
---
M src/core/osmo_io.c
1 file changed, 27 insertions(+), 0 deletions(-)
Approvals:
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 5d25f66..472edf9 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -409,6 +409,11 @@
{
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");
@@ -451,6 +456,11 @@
{
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");
@@ -499,6 +509,11 @@
int rc;
struct iofd_msghdr *msghdr;
+ 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_RECVMSG_SENDMSG);
if (OSMO_UNLIKELY(!iofd->io_ops.sendmsg_cb)) {
LOGPIO(iofd, LOGL_ERROR, "sendmsg_cb not set, Rejecting msgb\n");
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/35912?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I94be5ec7344d92157f7853c6c0ddf7007513ba8e
Gerrit-Change-Number: 35912
Gerrit-PatchSet: 9
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged