delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/04/18/06:22:40

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9B2A3857011
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1681813321;
bh=uuCYWDegKnyISuV7txFl+kmfkK9HKUb/gYFYobhxzPU=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=Q2S29UMkj7Mk/8pD8hxjDD/FZcCYfzhXi1TOoPUMhV2rQPfteA/bIBD82X0LjbIkn
n3NIb58F05wLAKrGtUbd5Pw+Fn1yq4BhjsYBY1Ny9XxwHVDK2WXS+Lw+iKhJaJrMgW
7rz2Jpz09DGuY8BLSMekGkwksVgW34Ty+cip07sY=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0A833856DD6
ARC-Seal: i=1; a=rsa-sha256; t=1681813304; cv=none;
d=strato.com; s=strato-dkim-0002;
b=dscTB5zEZOxNi1uW5lLkLBo6rr5llyHTHy2A0qyXkzrr340MqiyxOS/BnNiayZ7CpC
AoPbUeQYFb+6l7S9DTfxxrzYJjJ9iF3gXnagRc410qwXCuqFF7l9TV92CRVjvUZ/9LBz
z0WcIpcfsApckQanRZhPHl0f/VARhdS9egUolWIAdJGzZPxDMOZo2sAK26hiPHDoitFH
gJGSWESVioxgtyMCgWqZbj5Y27GMoKb5fS/dkj9jszOxAuP4fY5un9HKM560ucWlGbxZ
S1RWCQbk50EoiV9CAflvlUdJL0xmfE5rAkFP17GOZ9sEGsH4iS3XkEYzU3zjHyzI4zgO
qbGA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1681813304;
s=strato-dkim-0002; d=strato.com;
h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender;
bh=nGQBSG28OXmhzkuoN+Cbf2I6Urh+o0quBS07UdNTshg=;
b=RSDesu/pcoyZ5NAkh62u2Erf3fFiag+QkO5a2gumqrLol4r1yE1Lr3qZ/XEm7eJymN
5IJzmL5Uwz1W4Ik/A/j+kcRZ5thCmCatNfFnvDEQHVsmKuMrtOI0fymaaheAByQdudQ2
Ipg72Vb8zt+luqvpeV7xNBfNkuKXuzTIjaqk373E2mvfOG9z6HRbMsIR5ybyF5ccGeij
LvpQOEgxcQh5BiaJN+3X63s12Dfd63k6gDxFAQ6ERLg9Qu5m/8rW54+8qLkyjNaWXwlY
+qqNe0SjtQviuwBrku4GIlF2h8wsYMtGBug9XQE8k9PYP1fkD38kTCIX7okKdO3lsCJB
TO2w==
ARC-Authentication-Results: i=1; strato.com;
arc=none;
dkim=none
X-RZG-CLASS-ID: mo00
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpOT2vN+j99710EKugYHXkRHprwZvw=="
To: cygwin AT cygwin DOT com
Subject: wrong errno value set by readlinkat()
Date: Tue, 18 Apr 2023 12:21:43 +0200
Message-ID: <12553230.hYdu0Ggh8K@nimes>
MIME-Version: 1.0
X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS,
RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Bruno Haible via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Bruno Haible <bruno AT clisp DOT org>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Hi,

When an empty path argument is passed to the readlinkat() function,
POSIX:2018 specifies that the function fails with error ENOENT:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlinkat.html
"These functions shall fail if:
...
[ENOENT]
    A component of path does not name an existing file or path is an empty
    string."

In Cygwin 3.4.6, readlinkat() fails with error EBADF instead.

How to reproduce:
============================== foo.c ===================================
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main ()
{
  char buf[80];
  int ret = readlinkat (AT_FDCWD, "", buf, sizeof (buf));
  int err = errno;
  printf ("ret = %d, errno = %d = \"%s\"\n", ret, err, strerror (err));
  return 0;
}
========================================================================
$ gcc -Wall foo.c
$ ./a.exe

Expected output:
ret = -1, errno = 2 = "No such file or directory"

Actual output:
ret = -1, errno = 9 = "Bad file descriptor"


Bruno




-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019