From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Bart Samwel <bart@samwel.tk>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Buffer overrun in handle_notice_message()
Date: Sat, 19 Aug 2006 06:30:18 +0900
Message-ID: <44E6316A.5010301@tpf.co.jp> (raw)
In-Reply-To: <44E5CB09.1040005@samwel.tk>
References: <44E5CB09.1040005@samwel.tk>
Bart Samwel wrote:
> Hi all,
>
> I'd like to report a buffer overrun in handle_notice_message().
> Analysis: when I run a query >4096 characters that has a 'C' at a
> specific location (at a specific, small offset before a multiple of
> 4096), then the stack is trashed and the driver crashes. The code
> fragment:
>
> for (;;)
> {
> truncated = SOCK_get_string(sock, msgbuffer, sizeof(msgbuffer));
> if (!msgbuffer[0])
> break;
>
> mylog("%s: 'N' - %s\n", comment, msgbuffer);
> qlog("NOTICE from backend during %s: '%s'\n", comment, msgbuffer);
> switch (msgbuffer[0])
> {
> case 'S':
> strncat(msgbuf, msgbuffer + 1, buflen);
> strncat(msgbuf, ": ", buflen);
> buflen -= (strlen(msgbuffer) + 1);
> break;
> case 'M':
> strncat(msgbuf, msgbuffer + 1, buflen);
> msg_truncated = truncated;
> break;
> case 'C':
> if (sqlstate && !sqlstate[0] && strcmp(msgbuffer + 1,
> "00000"))
> strcpy(sqlstate, msgbuffer + 1);
> break;
> }
> }
Hi Bart,
Hmm, ISTM I should place the following code at the end of the above loop
not after the above code..
while (truncated)
truncated = SOCK_get_string(sock, msgbuffer,
sizeof(msgbuffer));
Actually I do so In handle_error_message().
I would fix it ASAP.
Thanks.
regards,
Hiroshi Inoue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: inoue@tpf.co.jp, bart@samwel.tk
Subject: Re: Buffer overrun in handle_notice_message()
In-Reply-To: <44E6316A.5010301@tpf.co.jp>
References: <44E5CB09.1040005@samwel.tk> <44E6316A.5010301@tpf.co.jp>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox