From owner-cvs-all Thu Aug 30 9:29: 1 2001 Delivered-To: cvs-all@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id F340837B40B; Thu, 30 Aug 2001 09:28:24 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [fec0::1:12]) by Awfulhak.org (8.11.5/8.11.5) with ESMTP id f7UGRqA71134; Thu, 30 Aug 2001 17:27:52 +0100 (BST) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.6/8.11.6) with ESMTP id f7UGRpf07792; Thu, 30 Aug 2001 17:27:51 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200108301627.f7UGRpf07792@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Mike Barcroft Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org, brian@freebsd-services.com Subject: Re: cvs commit: src/usr.bin/ftp util.c In-Reply-To: Message from Mike Barcroft of "Wed, 29 Aug 2001 16:51:14 PDT." <200108292351.f7TNpEx25148@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 30 Aug 2001 17:27:51 +0100 From: Brian Somers Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > mike 2001/08/29 16:51:14 PDT > > Modified files: > usr.bin/ftp util.c > Log: > o Fix some checks on snprintf(3) to prevent miscalculations. > o This fixes a memory leak that can occur on some URL's. > > Pointy hat to: brian > > Revision Changes Path > 1.21 +9 -5 src/usr.bin/ftp/util.c I don't think this fix is correct, it duplicates the checking of `n' too many times and overlooks the real bug (although avoiding it in the normal case). The correct fix (relative to util.c 1.20) is: Index: util.c =================================================================== RCS file: /home/ncvs/src/usr.bin/ftp/util.c,v retrieving revision 1.20 diff -u -r1.20 util.c --- util.c 2001/08/23 12:53:15 1.20 +++ util.c 2001/08/30 16:23:39 @@ -690,7 +690,7 @@ if (n > 0 && n < sizeof(buf) - len) len += n; i = remaining % SECSPERHOUR; - len += snprintf(buf + len, sizeof(buf) - len, + n = snprintf(buf + len, sizeof(buf) - len, "%02d:%02d ETA", i / 60, i % 60); } } -- Brian http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message