mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
1fc35d2557
commit
ed8cd1a9bd
|
@ -409,6 +409,11 @@ int osmo_iofd_write_msgb(struct osmo_io_fd *iofd, struct msgb *msg)
|
||||||
{
|
{
|
||||||
int rc;
|
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);
|
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_READ_WRITE);
|
||||||
if (OSMO_UNLIKELY(!iofd->io_ops.write_cb)) {
|
if (OSMO_UNLIKELY(!iofd->io_ops.write_cb)) {
|
||||||
LOGPIO(iofd, LOGL_ERROR, "write_cb not set, Rejecting msgb\n");
|
LOGPIO(iofd, LOGL_ERROR, "write_cb not set, Rejecting msgb\n");
|
||||||
|
@ -451,6 +456,11 @@ int osmo_iofd_sendto_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int sendto_
|
||||||
{
|
{
|
||||||
int rc;
|
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);
|
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_RECVFROM_SENDTO);
|
||||||
if (OSMO_UNLIKELY(!iofd->io_ops.sendto_cb)) {
|
if (OSMO_UNLIKELY(!iofd->io_ops.sendto_cb)) {
|
||||||
LOGPIO(iofd, LOGL_ERROR, "sendto_cb not set, Rejecting msgb\n");
|
LOGPIO(iofd, LOGL_ERROR, "sendto_cb not set, Rejecting msgb\n");
|
||||||
|
@ -499,6 +509,11 @@ int osmo_iofd_sendmsg_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int sendms
|
||||||
int rc;
|
int rc;
|
||||||
struct iofd_msghdr *msghdr;
|
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);
|
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_RECVMSG_SENDMSG);
|
||||||
if (OSMO_UNLIKELY(!iofd->io_ops.sendmsg_cb)) {
|
if (OSMO_UNLIKELY(!iofd->io_ops.sendmsg_cb)) {
|
||||||
LOGPIO(iofd, LOGL_ERROR, "sendmsg_cb not set, Rejecting msgb\n");
|
LOGPIO(iofd, LOGL_ERROR, "sendmsg_cb not set, Rejecting msgb\n");
|
||||||
|
|
Loading…
Reference in New Issue