From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 726E721363 for ; Thu, 23 May 2024 22:27:54 +0200 (CEST) Received: (qmail 13661 invoked by uid 550); 23 May 2024 20:27:49 -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 13617 invoked from network); 23 May 2024 20:27:48 -0000 Date: Thu, 23 May 2024 16:28:03 -0400 From: Rich Felker To: Florian Ziesche Cc: musl@lists.openwall.com Message-ID: <20240523202803.GC10433@brightrain.aerifal.cx> References: 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] [PATCH] dynlink: fix get_lfs64() with posix_fallocate64 On Fri, May 10, 2024 at 06:01:58PM +0200, Florian Ziesche wrote: > Hi, > > this patch increases the buffer size by one in get_lfs64() so that it > works with posix_fallocate64. > "posix_fallocate64" is 17 characters long, so 16 is one too short. > > Simplified example: > before: https://compiler-explorer.com/z/4qcPhcaWr > after: https://compiler-explorer.com/z/scGvhddKW > > --- > diff --git a/ldso/dynlink.c b/ldso/dynlink.c > index 42687da2..8707ae1c 100644 > --- a/ldso/dynlink.c > +++ b/ldso/dynlink.c > @@ -363,7 +363,7 @@ static struct symdef get_lfs64(const char *name) > "stat\0statfs\0statvfs\0tmpfile\0truncate\0versionsort\0" > "__fxstat\0__fxstatat\0__lxstat\0__xstat\0"; > size_t l; > - char buf[16]; > + char buf[17]; > for (l=0; name[l]; l++) { > if (l >= sizeof buf) goto nomatch; > buf[l] = name[l]; Thanks for catching this. I questioned whether the 17 is sufficient, but indeed the buffer is never nul terminated except when removing the 64, so it should be ok. I think I'll apply your patch as a direct fix, but the whole copying operation is unnecessary and I'll probably remove it. It works just as well to strncmp and pass p instead of buf to find_sym, so that a mutable copy of the name to lookup is never needed. Rich