From owner-freebsd-bugs@FreeBSD.ORG Thu Sep 10 20:40:03 2009 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 8FED8106568B for ; Thu, 10 Sep 2009 20:40: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 49F1B8FC14 for ; Thu, 10 Sep 2009 20:40:03 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n8AKe3fk081535 for ; Thu, 10 Sep 2009 20:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n8AKe3Fh081534; Thu, 10 Sep 2009 20:40:03 GMT (envelope-from gnats) Date: Thu, 10 Sep 2009 20:40:03 GMT Message-Id: <200909102040.n8AKe3Fh081534@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jilles Tjoelker Cc: Subject: Re: bin/57554: sh(1) incorrect handling of quoted parameter expansion X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2009 20:40:03 -0000 The following reply was made to PR bin/57554; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, mark@thuvia.org Cc: Subject: Re: bin/57554: sh(1) incorrect handling of quoted parameter expansion Date: Thu, 10 Sep 2009 22:31:18 +0200 Sorry for waiting so long with this. Your patch seems to work after fixing the conflicts (fairly easy). However, it (and also NetBSD /bin/sh) has a memory leak if there is a syntax error or SIGINT within 32 or more levels of variable expansion. Some possible fixes: - remove the dynamic allocation and just use the old broken way for level 32 and higher - add an exception handler when allocating dblquotep for the first time (not for all readtoken1 calls, that would probably be rather slow) - link it to a list pointed to by a global variable so it can be cleaned up eventually (note that things like ${X-$(printf %x ${Y-${Z}})} are possible so a single global does not do); this is somewhat similar to memalloc.c's "stack" which probably cannot be used for this as it is already used for assembling the resulting word -- Jilles Tjoelker