laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35063?usp=email )


Change subject: osmo_io: Reject unknown/unsupported modes in osmo_iofd_setup()
......................................................................

osmo_io: Reject unknown/unsupported modes in osmo_iofd_setup()

The current code does not check the value range of the 'mode' parameter
and would later run into OSMO_ASSERT(), rather than rejecting such a
mode from the very beginning.

Change-Id: I10dd612487638f456d0ad59c2cca203f1e098da3
Related: OS#5751
---
M src/core/osmo_io.c
1 file changed, 23 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/35063/1

diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 6677d34..c1a639a 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -448,6 +448,15 @@
        if (!iofd)
                return NULL;

+       /* reject unsupported/unknown modes */
+       switch (mode) {
+       case OSMO_IO_FD_MODE_READ_WRITE:
+       case OSMO_IO_FD_MODE_RECVFROM_SENDTO:
+               break;
+       default:
+               return NULL;
+       }
+
        iofd->fd = fd;
        iofd->mode = mode;
        IOFD_FLAG_SET(iofd, IOFD_FLAG_CLOSED);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35063?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: I10dd612487638f456d0ad59c2cca203f1e098da3
Gerrit-Change-Number: 35063
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to