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.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE 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 3698A29E10 for ; Mon, 10 Jun 2024 17:56:04 +0200 (CEST) Received: (qmail 11963 invoked by uid 550); 10 Jun 2024 15:56:00 -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 11922 invoked from network); 10 Jun 2024 15:55:59 -0000 Date: Mon, 10 Jun 2024 11:56:14 -0400 From: Rich Felker To: Valery Ushakov Cc: musl@lists.openwall.com, Nigel Kukard Message-ID: <20240610155613.GL10433@brightrain.aerifal.cx> References: <4b595a5b-2164-4bf2-af8b-80992eb0a0fe@LBSD.net> 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] Re: Different results with regex.h between Musl and Libc On Mon, Jun 10, 2024 at 02:47:04PM +0300, Valery Ushakov wrote: > On Mon, Jun 10, 2024 at 05:38:36 +0000, Nigel Kukard wrote: > > > Musl output (Alpine 3.20), musl-1.2.5-r1... > > > > The input '37' matches the pattern '^([0-9]*)?\.?([0-9]*)?$' > > Match 0: 37 > > Match 1: > > Match 2: 37 > > > > Glibc output (ArchLinux), glibc 2.39+r52+gf8e4623421-1... > > > > The input '37' matches the pattern '^([0-9]*)?\.?([0-9]*)?$' > > Match 0: 37 > > Match 1: 37 > > Match 2: > > I'm not sure what POSIX requires here. The closest I can find after > skimming through "9. Regular Expressions" is 9.4.6 that ends with: > > An ERE matching a single character repeated by an '*', '?', or an > interval expression shall not match a null expression unless this is > the only match for the repetition or it is necessary to satisfy the > exact or minimum number of occurrences for the interval expression. > > https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_06 > > I'm not sure what to read into the absense of the usual "or an ERE > enclosed in parentheses" chorus here. This looks like a bug. The general requirement (from memory; I don't have the spec in front of me now) is that each subexpression, in order from the beginning of the regex, matches the maximal-length input it can, subject to the overall constraint that the entire regex match the earliest (first priority) and maximal length (second priority) input it can. I guess we need to dig into why this is happening, ensure it's actually incorrect, and figure out how to fix it... Rich