Bug 175760 - readv(2) returns zero with vector count zero
Summary: readv(2) returns zero with vector count zero
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 4
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-12-14 18:15 UTC by William Kucharski
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version: man-pages-2.16-2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-12-15 09:52:19 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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.)


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