From owner-freebsd-security Thu Jul 19 11: 0:11 2001 Delivered-To: freebsd-security@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 10AAD37B405 for ; Thu, 19 Jul 2001 11:00:02 -0700 (PDT) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f6JHxmC68903; Thu, 19 Jul 2001 20:59:48 +0300 (EEST) (envelope-from ru) Date: Thu, 19 Jul 2001 20:59:48 +0300 From: Ruslan Ermilov To: Matt Dillon Cc: security@FreeBSD.ORG Subject: Re: [PATCH] Re: FreeBSD remote root exploit ? Message-ID: <20010719205948.D67829@sunbay.com> Mail-Followup-To: Matt Dillon , security@FreeBSD.ORG References: <5.1.0.14.0.20010719001357.03e22638@192.168.0.12> <014d01c11031$bdab5a10$2001a8c0@clitoris> <20010719201407.B61061@sunbay.com> <003701c11077$b3125400$0d00a8c0@alexus> <3B5718A0.2B650C9C@oksala.org> <200107191752.f6JHqer75736@earth.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200107191752.f6JHqer75736@earth.backplane.com>; from dillon@earth.backplane.com on Thu, Jul 19, 2001 at 10:52:40AM -0700 Sender: owner-freebsd-security@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Thu, Jul 19, 2001 at 10:52:40AM -0700, Matt Dillon wrote: > > :go to /usr/src/crypto/telnet/telnetd > :and type > :shell~# patch -p < /where/is/the/file.patch > > It isn't really safe code. If the data being formatted is large > r then the format argument you can overflow the buffer, and the > 'ret' from vsnprintf() is the amount of data that would have been > output if the buffer had been large enough, not the amount of data > that was actually output. Also, size_t is unsigned, which means > if you overflow the buffer by one byte you are screwed. > > There appear to be a number of places (mainly the DIAG code, but also > the ENCRYPT code) where this is true. This patch will fix the existing > options-based hole, but doesn't close it. > Doesn't this handle this? int output_data(const char *format, ...) { va_list args; size_t remaining, ret; va_start(args, format); remaining = BUFSIZ - (nfrontp - netobuf); /* try a netflush() if the room is too low */ if (strlen(format) > remaining || BUFSIZ / 4 > remaining) { ^^^^^^^^^^^^^^^^^^^^^^^^^^ netflush(); remaining = BUFSIZ - (nfrontp - netobuf); } ret = vsnprintf(nfrontp, remaining, format, args); nfrontp += ret; va_end(args); return ret; } -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message