tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

sendmsg/recvmsg not failing with msg_iovlen value 0 ?



Hi,

While creating tests for sendmsg(2)/recvmsg(2) to exercise the
syscalls under compat linux, i discovered that native versions does
not follow the documented behaviour.

According the the man pages, bit syscalls should fail with EMSGSIZE
when msg_iovlen member has a 0 value (following the OpenGroup
specification), but the current implementation do not obey and return
success instead.

     [EMSGSIZE]         The msg_iovlen member of the msg structure is less 
                        than or equal to 0 or is greater than {IOV_MAX}.

Does i miss something, or this needs to be fixed ?

NB: The attached code illutrate the current behaviour.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.
#include <sys/socket.h>

#include <err.h>
#include <string.h>
#include <unistd.h>

int main() {
  int res, sd[2];
  struct msghdr msg;

  res = socketpair(AF_UNIX, SOCK_STREAM, 0, sd);
  if (res == -1)
    err(1, "socketpair failed");

  memset(&msg, 0x0, sizeof(msg));
  res = sendmsg(sd[0], &msg, 0);
  if (res == -1)
    err(1, "sendmsg failed");

  memset(&msg, 0x0, sizeof(msg));
  res = recvmsg(sd[1], &msg, 0);
  if (res == -1)
    err(1, "recvmsg failed");

  res = close(sd[0]);
  if (res == -1)
    err(1, "close failed");

  res = close(sd[1]);
  if (res == -1)
    err(1, "close failed");

  return 0; }


Home | Main Index | Thread Index | Old Index