From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 4 09:20:03 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F84016A419 for ; Tue, 4 Sep 2007 09:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 035AD13C469 for ; Tue, 4 Sep 2007 09:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l849K2Dm064795 for ; Tue, 4 Sep 2007 09:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l849K29K064794; Tue, 4 Sep 2007 09:20:02 GMT (envelope-from gnats) Resent-Date: Tue, 4 Sep 2007 09:20:02 GMT Resent-Message-Id: <200709040920.l849K29K064794@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Rudolf Cejka Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 908C716A469 for ; Tue, 4 Sep 2007 09:16:59 +0000 (UTC) (envelope-from cejkar@fit.vutbr.cz) Received: from kazi.fit.vutbr.cz (kazi.fit.vutbr.cz [147.229.8.12]) by mx1.freebsd.org (Postfix) with ESMTP id 0E37A13C468 for ; Tue, 4 Sep 2007 09:16:58 +0000 (UTC) (envelope-from cejkar@fit.vutbr.cz) Received: from kazi.fit.vutbr.cz (localhost [127.0.0.1]) by kazi.fit.vutbr.cz (envelope-from cejkar@fit.vutbr.cz) (8.14.1/8.14.1) with ESMTP id l8496iiJ019646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 4 Sep 2007 11:06:44 +0200 (CEST) Received: (from cejkar@localhost) by kazi.fit.vutbr.cz (8.14.1/8.13.1/Submit) id l8496h8s019645; Tue, 4 Sep 2007 11:06:43 +0200 (CEST) (envelope-from cejkar) Message-Id: <200709040906.l8496h8s019645@kazi.fit.vutbr.cz> Date: Tue, 4 Sep 2007 11:06:43 +0200 (CEST) From: Rudolf Cejka To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/116074: [libc] fnmatch() does not handle FNM_PERIOD correctly X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Rudolf Cejka List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2007 09:20:03 -0000 >Number: 116074 >Category: bin >Synopsis: [libc] fnmatch() does not handle FNM_PERIOD correctly >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 04 09:20:02 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Rudolf Cejka >Release: FreeBSD 6.2-STABLE i386 >Organization: FIT, Brno University of Technology, Czech Republic >Environment: FreeBSD 6.2-STABLE, Aug 20, 2007 >Description: The example in How-To-Repeat does incorrectly return "Match: Yes (should be No)". The problem in fnmatch() is that the implementation finds first "*" character after "a" match, and then recursively tries to call itself, but now with FNM_PERIOD disabled: ... if (!fnmatch1(pattern, string, flags & ~FNM_PERIOD, patmbs, strmbs)) return (0); ... Tried patterns are fnmatch("b/*", "bbb/.x", ...) fnmatch("b/*", "bb/.x", ...) fnmatch("b/*", "b/.x", ...) where the third try is successfull, because the FNM_PERIOD is disabled. I tried to find a solution, but I'm afraid, that it is not so easy, because simply removing code disabling FNM_PERIOD could cause another problems (if there is a dot in asterisk matching pattern - maybe mangling stringstart inside recursive call with FNM_PERIOD allowed could do the job). >How-To-Repeat: #include #include int main(void) { int r = fnmatch("a*b/*", "abbb/.x", FNM_PATHNAME | FNM_PERIOD); printf("Match: %s\n", (r == 0) ? "Yes (should be No)" : "No"); return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: