logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Bug#247306: Fix for buffer overflow ready [was: Fwd: Bug#247306: odbc-postg: msg#00018

db.postgresql.odbc

Subject: Bug#247306: Fix for buffer overflow ready [was: Fwd: Bug#247306: odbc-postgresql: SIGSEGV with long inputs (> 10000 bytes)]

Hi again!

Sorry for crossposting, but I sent the initial post also to -bugs,
because I did not get an answer on -odbc.

On 2004-05-11 12:03 +0200, Martin Pitt wrote:
> I noticed Apache segfaulting when I feed a simple form with long inputs:
>
> [Tue May 4 11:32:10 2004] [notice] child pid 4084 exit signal
> Segmentation fault (11)
>
> Such inputs are used by php function odbc_connect as username and password to
> connect to a DSN using postgresql driver:
>
> $connection = @odbc_connect(DSN, $_POST['username'], $_POST['password'])
>
> The output of gdb is:
>
> (gdb) run -X -d apache
> [...]
> [Thread debugging using libthread_db enabled]
> [...]
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1076569920 (LWP 832)]
> 0x44c3d627 in SOCK_put_next_byte () from
> /usr/lib/postgresql/lib/psqlodbc.so
>
> Or:
> [same stuff here]
> 0x44c4c3d0 in strncpy_null () from /usr/lib/postgresql/lib/psqlodbc.so
>
> I suspect a security issue because playing around with long input strings of
> "A" I've been able to trigger in Apache error.log this message:
>
> free(): invalid pointer 0x41414141!
>
> 0x41 is obviously one of my "A"...

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.

The attached patch is for the current stable release 07.03.0200.

Thanks a lot to Peter Eisentraut for pointing me at the problem origin.

Unless you have a better idea it would be nice if you could apply the
patch to the official sources and also include it in the next release.

I will upload updated Debian packages for unstable and stable this
afternoon (16:00 CEST) if nobody reports a problem or a better
solution.

Thanks in advance,

Martin

--
Martin Pitt Debian GNU/Linux Developer
martin@xxxxxxxxx mpitt@xxxxxxxxxx
http://www.piware.de http://www.debian.org

Attachment: psqlodbc-make_string.patch
Description: Text document

Attachment: pgpmjBJz8qkzw.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo