X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 154ECD1B179 for ; Thu, 13 May 2004 14:43:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72114-01 for ; Thu, 13 May 2004 14:43:13 -0300 (ADT) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id D0B7BD1B181 for ; Thu, 13 May 2004 14:43:10 -0300 (ADT) Received: (qmail 29848 invoked by uid 65534); 13 May 2004 17:43:10 -0000 Received: from dsl-082-082-233-066.arcor-ip.net (EHLO colt.pezone.net) (82.82.233.66) by mail.gmx.net (mp015) with SMTP; 13 May 2004 19:43:10 +0200 X-Authenticated: #495269 From: Peter Eisentraut To: Martin Pitt , pgsql-bugs@postgresql.org, pgsql-odbc@postgresql.org Subject: Re: Fix for buffer overflow ready [was: Fwd: Bug#247306: odbc-postgresql: SIGSEGV with long inputs (> 10000 bytes)] Date: Thu, 13 May 2004 19:43:09 +0200 User-Agent: KMail/1.5.1 Cc: 247306@bugs.debian.org References: <20040511100357.GA23102@ifsr.de> <20040513094155.GA28717@ifsr.de> In-Reply-To: <20040513094155.GA28717@ifsr.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200405131943.09803.peter_e@gmx.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/90 X-Sequence-Number: 8362 Martin Pitt wrote: > The problem is that make_string() in misc.c does not check whether > the target buffer is big enough to hold the copied string. > > I added a bufsize parameter to make_string() and used it in all calls > to it. I tried it with my php4 crash test script and now it works > properly. Silently truncating various pieces of information is probably not the right thing. What are you truncating? If it's a query string you might open yourself up to SQL-injection type problems. Plus, the ODBC driver appears to have buffer overruns all over the place. We need to replace every instance of strcpy, strcat, sprintf, make_string, and the various other feeble attempts with pqexpbuffer from libpq. That's the only way to solve this problem once and for all.