﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
344	fcntl(F_DUPFD) sets wrong errno	dmik		"If you pass an invalid file descriptor to the `fcntl(F_DUPFD)` call, it will return -1 and set `errno` to `EPERM`. This is wrong as according to the specs it should set it to `EBADF` in such a case (and it does so on *nix).

Here is the test case proving that:
{{{
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>

int main()
{
    int fd = 100; // must be an invalid fd
    int flags = fcntl(fd, F_GETFL);
    printf (""fcntl(%d,F_GETFL)=%d errno=%d\n"", fd, flags, errno);

    int fd2 = fcntl(fd, F_DUPFD, 200);
    printf (""dupfd(%d,200,F_DUPFD)=%d errno=%d\n"", fd, fd2, errno);

    return 0;
}
}}}"	defect	new	normal	libc-0.7	libc	0.6.6	normal			
