From owner-cvs-lib Mon Mar 17 14:18:44 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id OAA08245 for cvs-lib-outgoing; Mon, 17 Mar 1997 14:18:44 -0800 (PST) Received: from gvr.win.tue.nl (root@gvr.win.tue.nl [131.155.210.19]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA08234; Mon, 17 Mar 1997 14:18:24 -0800 (PST) Received: (from guido@localhost) by gvr.win.tue.nl (8.8.5/8.8.2) id XAA17493; Mon, 17 Mar 1997 23:18:09 +0100 (MET) From: Guido van Rooij Message-Id: <199703172218.XAA17493@gvr.win.tue.nl> Subject: Re: cvs commit: src/lib/libtermcap tgoto.c In-Reply-To: <199703172107.IAA27478@godzilla.zeta.org.au> from Bruce Evans at "Mar 18, 97 08:07:04 am" To: bde@zeta.org.au (Bruce Evans) Date: Mon, 17 Mar 1997 23:18:09 +0100 (MET) Cc: eivind@freefall.freebsd.org, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-lib@freefall.freebsd.org X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-cvs-lib@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > >Shouln't you \0-terminate the copied string? This was suggested in the > >same article. > > The string is terminated by strcpy. The article was talking about an > allegedly bad fix that used strncpy. strncpy is OK if the final byte > of the array is never changed from its intial value of 0. > > >Further, there is a strcpy on the end. That should also be fixed. > > No, it is correct, except for a minor bug in the overflow checking. > I sent private mail to Eivind about it. > > >I think the if statements should be something like: > >if (dp >= &result[MAXRETURNSIZE-1]) > > This would ensure space for the terminator, but the check at the end > already does that. What check? I don;t see any check. According to me, the complete buffer can now be filled with non-NUL bytes and afterwards even extended by sizeof(added). If added is "", then still the NUL would be one off. -Guido