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 22980 invoked from network); 25 Nov 2020 15:04:13 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 25 Nov 2020 15:04:13 -0000 Received: (qmail 22178 invoked by uid 550); 25 Nov 2020 15:04:10 -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 22151 invoked from network); 25 Nov 2020 15:04:10 -0000 Date: Wed, 25 Nov 2020 10:03:58 -0500 From: Rich Felker To: Alexey Izbyshev Cc: musl@lists.openwall.com Message-ID: <20201125150357.GH534@brightrain.aerifal.cx> References: <20201122225619.GR534@brightrain.aerifal.cx> <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> <20201124203132.GE534@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] realpath without procfs -- should be ready for inclusion On Wed, Nov 25, 2020 at 08:40:02AM +0300, Alexey Izbyshev wrote: > I don't see why the size of stack has to be PATH_MAX+1 though. To > address the issue with symlink targets of PATH_MAX-1 length, it > seems sufficient to just do the following: > > - ssize_t k = readlink(output, stack, p); > - if (k==p) goto toolong; > + ssize_t k = readlink(output, stack, p+1); > + if (k==p+1) goto toolong; > > Since p is never past the end of the stack, there is no harm in > allowing k == p. Indeed. I think I was concerned about it clobbering the first byte of the live part of the stack, but on error the stack is discarded anyway, so that seems to be a non-issue. Rich