From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Ludek Finstrle <luf@pzkagis.cz>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Patch for snprintf problem (bug #1000650)
Date: Fri, 09 Jun 2006 08:46:50 +0900
Message-ID: <4488B6EA.9050107@tpf.co.jp> (raw)
In-Reply-To: <20060607173910.GA28221@soptik.pzkagis.cz>
References: <20060607173910.GA28221@soptik.pzkagis.cz>
Ludek Finstrle wrote:
> Hello,
>
> I found the problem in snprintf on linux (maybe another unix) boxes
> in info.c (CVS HEAD). The problematic part is something like:
>
> buf = "text";
> snprintf(buf,size,"%s append",buf);
>
> buf = "text append" on Windows (MS VC compiler)
> buf = " append" on linux (gcc compiler)
>
> I solve it this way (main idea):
> snprintf(buf + strlen(buf), " append");
Hmm bad news.
If so, it may be better to use the sequence like the following for example.
char *query_ptr;
size_t bufsize_res;
int slen;
/* Initialize */
query_ptr = columns_query;
bufsize_res = sizeof(columns_query);
if (..)
{
if ((slen = snprintf(query_ptr, bufsize_res, .., )) <= 0)
{
.. error_handling ..
}
query_ptr += slen;
bufsize_res -= slen;
}
...
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, luf@pzkagis.cz
Subject: Re: Patch for snprintf problem (bug #1000650)
In-Reply-To: <4488B6EA.9050107@tpf.co.jp>
References: <20060607173910.GA28221@soptik.pzkagis.cz> <4488B6EA.9050107@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