|
Message-Id: <em49678e47-63a6-45c1-a340-0fc82821304d@0b277051.com> Date: Mon, 11 Mar 2024 21:21:00 +0000 From: "Laurent Bercot" <ska-dietlibc@...rnet.org> To: musl@...ts.openwall.com, "Skyler Ferrante (RIT Student)" <sjf5462@....edu> Cc: "Andreas Schwab" <schwab@...e.de>, "Alejandro Colomar" <alx@...nel.org>, "Thorsten Glaser" <tg@...bsd.de>, musl@...ts.openwall.com, NRK <nrk@...root.org>, "Guillem Jover" <guillem@...rons.org>, libc-alpha@...rceware.org, libbsd@...ts.freedesktop.org, "Serge E. Hallyn" <serge@...lyn.com>, "Iker Pedrosa" <ipedrosa@...hat.com>, "Christian Brauner" <christian@...uner.io> Subject: Re: Re: Tweaking the program name for <err.h> functions >(Aside: making _FORTIFY_SOURCE>1 trap close(n) with n<3 would be an >interesting idea... :) Please don't. close(0); if (open("something", O_RDONLY)) fail(); (only when single-threaded, obviously) is a valid pattern, and uses one fewer descriptor than fd=open("something", O_RDONLY); dup2(fd, 0); Also, running with stdin or stdout closed (or even stderr but what kind of monster would do that) is fine for a process that is internal to a project, that isn't user-facing; it's on the project to know the fd states of its various components. Private APIs should not have the same constraints as public ones. (And yes, for user-facing programs, i.e. 99% of them, it is a good idea to always sanitize around 0, 1 and 2.) -- Laurent
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.