From owner-freebsd-bugs@FreeBSD.ORG Sat Jan 30 10:00:08 2010 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 79ADB1065672 for ; Sat, 30 Jan 2010 10:00:08 +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 5398B8FC1A for ; Sat, 30 Jan 2010 10:00:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o0UA08Pe004906 for ; Sat, 30 Jan 2010 10:00:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o0UA08f5004905; Sat, 30 Jan 2010 10:00:08 GMT (envelope-from gnats) Resent-Date: Sat, 30 Jan 2010 10:00:08 GMT Resent-Message-Id: <201001301000.o0UA08f5004905@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, Mikolaj Golub Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 884C51065672 for ; Sat, 30 Jan 2010 09:50:01 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 7811B8FC14 for ; Sat, 30 Jan 2010 09:50:01 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0U9o1kC038894 for ; Sat, 30 Jan 2010 09:50:01 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o0U9o1bm038891; Sat, 30 Jan 2010 09:50:01 GMT (envelope-from nobody) Message-Id: <201001300950.o0U9o1bm038891@www.freebsd.org> Date: Sat, 30 Jan 2010 09:50:01 GMT From: Mikolaj Golub To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/143365: [patch] incorrect regexp matching in awk(1) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 10:00:08 -0000 >Number: 143365 >Category: bin >Synopsis: [patch] incorrect regexp matching in awk(1) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 30 10:00:07 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Mikolaj Golub >Release: 8.0-STABLE, 7.2-STABLE >Organization: >Environment: FreeBSD zhuzha.ua1 8.0-STABLE FreeBSD 8.0-STABLE #6: Sun Jan 24 21:36:17 EET 2010 root@zhuzha.ua1:/usr/obj/usr/src/sys/GENERIC i386 >Description: This problem with awk(1) regexp working incorrectly was reported to NetBSD by Aleksey Cheusov and it was fixed there. http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=38737 FreeBSD version still has this bug: kopusha:~% printf '\t\n' | LC_CTYPE=C awk '/^[[:cntrl:]]/ {print "It is ok"}' It is ok kopusha:~% printf '\t\n' | LC_CTYPE=C awk '/^[[:cntrl:]]$/ {print "It is ok"}' kopusha:~% >How-To-Repeat: printf '\t\n' | LC_CTYPE=C awk '/^[[:cntrl:]]$/ {print "It is ok"}' >Fix: See the attached patch adopted from NetBSD (don't build the character class table starting at 0, because will always be treated as the empty string). Patch attached with submission follows: diff -ru contrib/one-true-awk.orig/b.c contrib/one-true-awk/b.c --- contrib/one-true-awk.orig/b.c 2007-06-05 18:33:51.000000000 +0300 +++ contrib/one-true-awk/b.c 2010-01-30 11:37:15.000000000 +0200 @@ -818,7 +818,7 @@ if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' && prestr[2 + cc->cc_namelen] == ']') { prestr += cc->cc_namelen + 3; - for (i = 0; i < NCHARS; i++) { + for (i = 1; i < NCHARS; i++) { if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2")) FATAL("out of space for reg expr %.10s...", lastre); if (cc->cc_func(i)) { >Release-Note: >Audit-Trail: >Unformatted: