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 25875 invoked from network); 25 Nov 2021 15:52:17 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 25 Nov 2021 15:52:17 -0000 Received: (qmail 29758 invoked by uid 550); 25 Nov 2021 15:52:15 -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 29726 invoked from network); 25 Nov 2021 15:52:14 -0000 Date: Thu, 25 Nov 2021 10:52:00 -0500 From: Rich Felker To: "Quesada Gonzalez, Elena" Cc: "musl@lists.openwall.com" Message-ID: <20211125155200.GB7074@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] SIGSEV error when using REGEX with musl library On Thu, Nov 25, 2021 at 02:53:13PM +0000, Quesada Gonzalez, Elena wrote: > I have the following function that works fine if the regular expression is correct, but get a SIGSEGV when calling regex_search compiling with clang-9 and using musl 1.2. > However, it works fine with glibc, > > Could be a bug in musl library? > > > Find code below > > void CRuntimeCommandLine::LoadComplement(const multimap& mapArguments) > { > // Find parameter > multimap::const_iterator iter; > iter = mapArguments.find("Complement"); > if(iter == mapArguments.end()) > { > // Only fatal. Statement is not initialized yet. > Logger::fatal(Errors::RCMD_F005_MISSING_MANDATORY_PARAM, "Missing mandatory parameter --Complement"); > } > // regex expression for system_secret to be checked (Max 4Bytes, hexadecimal number in lowe case letters and no 0x format) > regex regexp("^[0-9a-f]{1,8}$"); > > // regex_search that searches pattern regexp in the string mystr > std::string s = iter->second.c_str(); > if (false == std::regex_search(s, regexp)) > { > // Only fatal. Statement is not initialized yet. > Logger::fatal(Errors::RCMD_F006_INVALID_VALUE, "Invalid --Complement=hexvalue value"); > } > else > { > // get hexadecimal value > (void)sscanf(s.c_str(), "%X", &(m_cmdParameters.complementValue)); > } > > } > With kind regards > Elena Quesada Gonzalez Do you have a complete minimal-ish test case that can be compiled and show the same thing happening? Even just a dummy main() to call the above the way you expect it to be called? Rich