From owner-freebsd-bugs@FreeBSD.ORG Wed Aug 2 01:50:33 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 300EB16A4DD for ; Wed, 2 Aug 2006 01:50:33 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 439A943D69 for ; Wed, 2 Aug 2006 01:50:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k721oHQo085505 for ; Wed, 2 Aug 2006 01:50:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k721oHOw085503; Wed, 2 Aug 2006 01:50:17 GMT (envelope-from gnats) Date: Wed, 2 Aug 2006 01:50:17 GMT Message-Id: <200608020150.k721oHOw085503@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Nate Eldredge Cc: Subject: Re: bin/99985: make(1) crashes with invalid continuation lines X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nate Eldredge List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Aug 2006 01:50:33 -0000 The following reply was made to PR bin/99985; it has been noted by GNATS. From: Nate Eldredge To: bug-followup@FreeBSD.org, ltsampros@upnet.gr Cc: Subject: Re: bin/99985: make(1) crashes with invalid continuation lines Date: Tue, 1 Aug 2006 18:49:49 -0700 (PDT) Well, here is a patch which fixes this bug. Though I'm a little confused as to the behavior of the code anyway. In brk_string in str.c, if expand == 0, a backslash causes itself and the following character to be copied to the output, without processing. If the following character is the terminating null, then it won't be noticed, and we'll march happily beyond the end of the string (and maybe crash, or maybe not). So this patch fixes that. However, the behavior seems odd in general. For instance, as it stands the string "foo\ bar" is a single argument, whereas "foo/ bar" is two args: {"foo/", "bar"}. I don't understand what the correct semantics should be. Note the bug has been present since revision 1.3, which apparently was imported from NetBSD for FreeBSD 2.0.5, back in 1995. In May 2005 we imported a version from DragonFlyBSD by Max Okumoto, who largely rewrote the function, keeping the bug intact! --- /usr/src/usr.bin/make/str.c Mon May 23 06:27:52 2005 +++ str.c Tue Aug 1 18:25:34 2006 @@ -260,8 +260,14 @@ } } else { *arg++ = str[0]; - ++str; - *arg++ = str[0]; + /* + * FIXME: Why does a backslash protect + * the next character even with expand=0 ? + */ + if (str[1]) { + ++str; + *arg++ = str[0]; + } } break; default: -- Nate Eldredge nge@cs.hmc.edu