laforge has submitted this change. ( 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, 26 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c index 1a8c01d..8507f46 100644 --- a/src/core/osmo_io.c +++ b/src/core/osmo_io.c @@ -445,7 +445,18 @@ struct osmo_io_fd *osmo_iofd_setup(const void *ctx, int fd, const char *name, enum osmo_io_fd_mode mode, const struct osmo_io_ops *ioops, void *data) { - struct osmo_io_fd *iofd = talloc_zero(ctx, struct osmo_io_fd); + struct osmo_io_fd *iofd; + + /* 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 = talloc_zero(ctx, struct osmo_io_fd); if (!iofd) return NULL; -- 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: 3 Gerrit-Owner: laforge <lafo...@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillm...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-MessageType: merged