Bug 175760

Summary: readv(2) returns zero with vector count zero
Product: [Fedora] Fedora Reporter: William Kucharski <kucharsk>
Component: kernelAssignee: Ivana Varekova <varekova>
Status: CLOSED CURRENTRELEASE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 4   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: man-pages-2.16-2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-12-15 09:52:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description William Kucharski 2005-12-14 18:15:55 UTC
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 09:52:19 UTC
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.)