From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9892 invoked from network); 8 Oct 2020 16:23:51 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 8 Oct 2020 16:23:51 -0000 Received: (qmail 5634 invoked by uid 550); 8 Oct 2020 16:23:47 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 5613 invoked from network); 8 Oct 2020 16:23:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1602174215; bh=JyJvKO5GusbqGAhKjEZiOo90WLwnVUVSa0SJcVbYmWM=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=E2DIZpSO0ZIJ31MTKKDgLqT997tj4qnN9bIoVZQGFG4WYi2M9jtFEOLTZLlIZHhxF qUcwGy2BUMjMOc5eqgkkgofXmcr2xr5OhM7hJFB5mk8aP+WrNGUOhRrSg2JS4OQyVq l4jgcvEG4p4mU/4805sI9YNHtcvqlxgFghFJoPrw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Date: Thu, 8 Oct 2020 18:23:34 +0200 From: Markus Wichmann To: John Scott Cc: musl@lists.openwall.com Message-ID: <20201008162334.GC7997@voyager> References: <20475045.GjpEljjT90@t450> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20475045.GjpEljjT90@t450>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ygwFAZkJyK7XQDTa9fkuWWRPqUFeURzS4Z//xFzTvD0iKG8Ys19VVPYFBrS/ZU EBJ27MQi2P1ofNrzwbtJnc2UgeIcQ1M2w48jDDYhJtbyUUISdgC9CMi2rtPhgNBD2ApvXCGQi ZBMCS/2RdF8YEDbaNKPXJeD/gfLbN7cALHIU/Bk+QkHmaCGIJBKNtiNg2Nae4rL9nmgxZnmvF JWRUuSxnIEqGFjTeMfyK5M52VjrooENSWqP2VS0C5jJIo94SIiSgiIFeuT+MJQMzSnQzU6awQ vCL1kH6g49Wh+CjEp1jfwDrtzju8Dat5sDa/h0iQ/us2viMmnJVU82kCFJZ+1/TUFzZbh/EQs m0YNiTsxfAFReMEiETmxPgeZ1Qc9V7kX/vR4nz64hfKrvo3iDIvk+UNr99qcl7Fr/lGET+DYo uLRQLeH5dxvBMb+s6np4tfTCI+j6+M5JQzU0ygh68+KWIalkYuoN2YyfqvnOBjO3Cw5pLLu+Z IAlrAI8MR0vZMIkks Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] fputs/fputc doesn't set errno on failure On Thu, Oct 08, 2020 at 10:55:47AM -0400, John Scott wrote: > Hi, > > I'm not subscribed, please keep me CC'd. > Here's hoping I chose the correct option this time. I went with "group reply" but directed the message to you, which should CC the list. > In this corner case, errno is unset despite fputs giving an error. I'm o= n Debian testing using musl-gcc 1.2.1. > > #define _POSIX_C_SOURCE 200809L > #include > #include > #include > int main(void) { > FILE *f =3D fopen("/", "r"); > if(f =3D=3D NULL) { > perror("fopen()"); > } > if(fputs("Hello world\n", f) =3D=3D EOF) { > assert(errno); > perror("fputs()"); > } > } > > With glibc this prints EBADF for fputs. > Interesting. The error occurs because f is only open for reading, so __towrite() delivers an error without setting errno. Though my POSIX manpage does not say which error to return for this. EBADF speaks about the FD underlying the stream, and in this case that one happens to be the case, but the error occurs solely because F_NOWR is set in the file. The FD does not come into play. On the other hand, using fdopen() such that the mode given to open() and the string given to fdopen() are discordant is undefined behavior. So we might as well assume that F_NOWR means O_RDONLY. Besides, no other documented error on that page really fits this case. I suggest adding error codes to the error paths in __towrite() and __toread() (which has the same problem). > The wiki page about writing tests [1], which I thought this would be a g= ood candidate for, has the 404 link http://nsz.repo.hu/git/?p=3Dlibc-test It would appear Szabolcs' repo is broken. I cannot access .../git/, but accessing .../ yields a landing page that references the non-working pages given here. I managed to find a mirror here: https://repo.or.cz/libc-test.git But that one also reference Szabolcs' repo as the original. Ciao, Markus