Bug 175760 - readv(2) returns zero with vector count zero
readv(2) returns zero with vector count zero
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
4
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Ivana Varekova
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-12-14 13:15 EST by William Kucharski
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: man-pages-2.16-2
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-12-15 04:52:19 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description William Kucharski 2005-12-14 13:15:55 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 Firefox/1.0.7

Description of problem:
The readv(2) man page states this about error values:

       EINVAL The sum of the iov_len values overflows an  ssize_t  value.  Or,
              the vector count count is zero or greater than IOV_MAX.

However a test program shows passing an iovec of 0 will return 0 for both readv() and writev().

Version-Release number of selected component (if applicable):
kernel-2.6.14-1.1637_FC4

How reproducible:
Always

Steps to Reproduce:
1. Compile this program as iov.c:

#include <sys/uio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>

main()
{
        int fd, ret;
        struct iovec iov;
        char buf[128];

        if ((fd = open("iov.c", O_RDWR)) < 0) {
                perror("failed to open iov.c");
                exit(1);
        }

        iov.iov_base = buf;
        iov.iov_len = 128;

        if ((ret = readv(fd, &iov, 0)) < 0)
                perror("readv");
        else
                printf("readv returned %d\n", ret);

        if ((ret = writev(fd, &iov, 0)) < 0)
                perror("writev");
        else
                printf("writev returned %d\n", ret);

        close(fd);
        exit(0);
}

2. Run a.out

  

Actual Results:  readv returned 0
writev returned 0


Expected Results:  Both calls should have returned -1 with errno set to EINVAL.

Additional info:

This may be either a man page error or a bug in the kernel; a decision needs to be made by the kernel developers as to whether the call or the man page is in error.
Comment 1 Ivana Varekova 2005-12-15 04:52:19 EST
This bug is fixed in the last version of man-pages (man-pages-2.16-2) 
( EINVAL The sum of the iov_len values overflows an  ssize_t  value.  Or,
              the  vector  count  count  is less than zero or greater than the
              permitted maximum.)

Note You need to log in before you can comment on or make changes to this bug.