From patchwork Mon Mar 26 09:50:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10307513 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D8B1860212 for ; Mon, 26 Mar 2018 09:50:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE0CE2961F for ; Mon, 26 Mar 2018 09:50:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B26BB29621; Mon, 26 Mar 2018 09:50:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 017942961F for ; Mon, 26 Mar 2018 09:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751099AbeCZJuc (ORCPT ); Mon, 26 Mar 2018 05:50:32 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:34312 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbeCZJuc (ORCPT ); Mon, 26 Mar 2018 05:50:32 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtp (Exim 4.84_2 #2 (Debian)) id 1f0Oln-0000gL-CQ; Mon, 26 Mar 2018 17:50:27 +0800 Received: from herbert by gondobar with local (Exim 4.84_2) (envelope-from ) id 1f0Olk-0002FK-Te; Mon, 26 Mar 2018 17:50:25 +0800 Date: Mon, 26 Mar 2018 17:50:24 +0800 From: Herbert Xu To: Harald van Dijk Cc: DASH Mailing List Subject: [PATCH v2] expand: Fix glibc glob(3) support Message-ID: <20180326095024.GA8580@gondor.apana.org.au> References: <20180325080609.GA5452@gondor.apana.org.au> <2ce7ae12-f507-d702-89ef-f9f851c5bc40@gigawatt.nl> <20180325162741.GA5751@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180325162741.GA5751@gondor.apana.org.au> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Mar 26, 2018 at 12:27:41AM +0800, Herbert Xu wrote: > > I tried making it work, and it looks like it should work with > the latest glibc as they have just fixed a critical issue that > would otherwise require nasty hacks to work around: > > https://sourceware.org/bugzilla/show_bug.cgi?id=866 > > So I'll give it some time to filter through before trying it again. OK, with this patch and glibc 2.27 it appears to be working: ---8<--- It's been a while since we disabled glob(3) support by default. It appears to be working now, however, we have to change our code to detect the no-match case correctly. In particular, we need to test for GLOB_NOMAGIC | GLOB_NOCHECK instead of GLOB_MAGCHAR. Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index 705fef7..bc1f760 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1188,7 +1188,8 @@ expandmeta(str, flag) ckfree(p); switch (i) { case 0: - if (!(pglob.gl_flags & GLOB_MAGCHAR)) + if ((pglob.gl_flags & (GLOB_NOMAGIC | GLOB_NOCHECK)) == + (GLOB_NOMAGIC | GLOB_NOCHECK)) goto nometa2; addglob(&pglob); globfree(&pglob);