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.3 required=5.0 tests=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 22176 invoked from network); 24 Nov 2020 20:17:54 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 24 Nov 2020 20:17:54 -0000 Received: (qmail 17843 invoked by uid 550); 24 Nov 2020 20:17: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 17819 invoked from network); 24 Nov 2020 20:17:46 -0000 Date: Tue, 24 Nov 2020 15:17:33 -0500 From: Rich Felker To: Alexey Izbyshev Cc: musl@lists.openwall.com Message-ID: <20201124201733.GD534@brightrain.aerifal.cx> References: <97dd3cf7c69673e5962e9ccd46ea5131@ispras.ru> <20201123031932.GS534@brightrain.aerifal.cx> <20201123185633.GY534@brightrain.aerifal.cx> <20201123205259.GZ534@brightrain.aerifal.cx> <48faf5ab9a1f3c869c85897217db0d75@ispras.ru> <20201124042646.GA534@brightrain.aerifal.cx> <20201124063048.GB534@brightrain.aerifal.cx> <20201124143555.GC534@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201124143555.GC534@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] realpath without procfs -- should be ready for inclusion On Tue, Nov 24, 2020 at 09:35:55AM -0500, Rich Felker wrote: > On Tue, Nov 24, 2020 at 12:21:36PM +0300, Alexey Izbyshev wrote: > > On 2020-11-24 09:30, Rich Felker wrote: > > >I think before this goes upstream we should have a good set of > > >testcases that can be contributed to libc-test. Do you have ideas for > > >coverage? Some that come to mind: > > > > > Added some more ideas. > > > > [...] > > - An argument ending with an absolute symlink with the target having > > length PATH_MAX-1 (valid path) > > > > Hm, the last one doesn't work now. Since p is the position of NUL > > instead of the size of stack, "if (k==p) goto toolong;" forbids > > symlinks with the length of the target == PATH_MAX-1. > > This should be fixable just by increasing size of stack to PATH_MAX+1. > In theory it doesn't need to be null-terminated but then strchrnul > won't work. memchr would work instead but it's slightly less > convenient to use. One thing I noticed while working out test ideas: my very early observation that we can use the caller's buffer for output is wrong. The spec allows it to have been clobbered on failure but not on success; there's nothing allowing write past the resulting string size. It's not too bad to have two 4k buffers, but I think we can actually put them together. PATH_MAX+1 isn't quite enough because, when expanding a link, we momentatily need space for both the link name and contents. However PATH_MAX+NAME_MAX+2 should suffice, since at most a NAME_MAX part is being removed before pushing the link contents onto the stack. I don't really feel like making this improvement now though; it's better done as a change later if desired. Rich