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 D57A2D1D2A7 for ; Tue, 11 May 2004 20:47:47 -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 78600-05 for ; Tue, 11 May 2004 20:47:30 -0300 (ADT) Received: from web08.manitu.net (web08.manitu.net [217.11.48.108]) by svr1.postgresql.org (Postfix) with ESMTP id DA551D1B226 for ; Tue, 11 May 2004 20:47:26 -0300 (ADT) Received: (from mpitt@localhost) by web08.manitu.net (8.10.2-SOL3/8.10.2) id i4BNl9g22490; Wed, 12 May 2004 01:47:09 +0200 Date: Wed, 12 May 2004 01:47:09 +0200 From: Martin Pitt To: pgsql-bugs@postgresql.org, Peter Eisentraut Cc: 247306@bugs.debian.org Subject: Re: Fwd: Bug#247306: odbc-postgresql: SIGSEGV with long inputs (> 10000 bytes) Message-ID: <20040511234709.GB21484@web08.manitu.net> Mail-Followup-To: Martin Pitt , pgsql-bugs@postgresql.org, Peter Eisentraut , 247306@bugs.debian.org References: <20040511100357.GA23102@ifsr.de> <200405120130.16067.peter_e@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200405120130.16067.peter_e@gmx.net> User-Agent: Mutt/1.4.1i 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/78 X-Sequence-Number: 8350 Hi! On 2004-05-12 1:31 +0200, Peter Eisentraut wrote: > Martin Pitt wrote: > > A week ago we at Debian received the bug report below: due to a > > buffer overflow in psqlodbc it is possible to crash (and possibly > > exploit) apache. I already sent this mail to the psqlodbc list [1], > > but unfortunately got no response so far. So maybe there are some > > hackers here who can help with this? > > The problem is that the ODBC driver just writes the long user name or > password into its internal data structures without paying attention the > fact that it's only got 256 bytes of space. (function PGAPI_Connect in > file connection.c) It's the oldest bug in the book really. Thanks for this hint and spotting the error, I think I see the problem now: PGAPI_Connect calls make_string(szDSN, cbDSN, ci->dsn); to copy the string (and similar with uid and password). ci->dsn is only MEDIUM_REGISTRY_LEN (256) bytes big, so if cbDSN >= 256, it will crash. So I suppose the function just has to check the cb* values, and if one of them is >= 256, return an appropriate error? Another possibility would be to add a fourth argument to make_string that specifies the size of the target buffer (and have it copy max(stringlen, bufferlen-1) bytes). This would force the correction of all places where make_string is used (just 13, so it should not get too hard). Any comments to that? Thanks, Martin -- Martin Pitt Debian GNU/Linux Developer martin@piware.de mpitt@debian.org http://www.piware.de http://www.debian.org