From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22602 invoked by alias); 27 Nov 2013 20:26:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32062 Received: (qmail 15348 invoked from network); 27 Nov 2013 20:26:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=E8gj7soxFuWqClvESXBdIVC/DMOVBEm8w/kgUswTT7E=; b=h9qFg8dJV0F3Q3ho2pu6Ky+LoikjCOmKjR0yh+P+kBMR+qvCwPUnGvjMNZxGI+4XB5 PYJra8UeA6lkDsPBUVBcTAx8gP/wL2DM630R9YpmGhnbsQtGD+ws4tSz4MvmHCoAqF+m lU8+TkH+u8IkFOf8OGCCb7i6wf/bwwmHAQaS//QkBrrOq/QConOgA+B6j21qUG0trzec TU42oUB4OmAngXlkqCmKW0rElgsE9n+ZZVMDLiEijwOJqkM4AfxSbyLj06I2BULFkdHd KHKoxoM8K88UmLnLSHqe3PeCO2W2zVL2ZPl8x0J14nETBSRpyKMM00niJgWXeoz/GJfW Kj4Q== X-Gm-Message-State: ALoCoQlfTLKEGkznzgSkzSude+vohUhLSQNOgHlyCUUvOLADjb9F4VeXfdVtUmENjwPiO5XtE3nc X-Received: by 10.194.118.198 with SMTP id ko6mr77981wjb.90.1385583965511; Wed, 27 Nov 2013 12:26:05 -0800 (PST) X-ProxyUser-IP: 86.6.157.246 Date: Wed, 27 Nov 2013 20:26:02 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: PATCH: utils.c: Fix use of uninitialized memory in metafy(). Message-ID: <20131127202602.3897f501@pws-pc.ntlworld.com> In-Reply-To: <131127105409.ZM10472@torch.brasslantern.com> References: <20131127180719.1ad6acf0@pwslap01u.europe.root.pri> <131127105409.ZM10472@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 27 Nov 2013 10:54:09 -0800 Bart Schaefer wrote: > On Nov 27, 6:07pm, Peter Stephenson wrote: > } > } Hmm... I think the intention probably *is* to check if there's null > } termination at "buf + len", on the assumption that the first "len" bytes > } need metafying regardless. So if we've got only len valid bytes, not > } null-terminated (or null-terminated by accident because the next byte > } that isn't actually valid for the allocation happens to be null), we've > } got no way of knowing this given the current interface. > > Does it actually matter? The only reason for (*e != 0) as far as I can > tell is to be sure we've actually done (*e = '\0') at the very end of > the whole thing [comment: "... unchanged (a terminating null character > is appended to buf if necessary)"]. > > Can't we just move the *e = '\0' outside the "if" body and skip the test > in the condition? Seems reasonable --- it requires the problem Simon was seeing to be in a case that's requesting reallocation, else that assignment is going to cause problems, but if it does cause problems we need to change the caller. pws