From: Ludek Finstrle <luf@pzkagis.cz>
To: Hiroshi Inoue <inoue@tpf.co.jp>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Patch for snprintf problem (bug #1000650)
Date: Fri, 9 Jun 2006 10:16:37 +0200
Message-ID: <20060609081637.GA8153@soptik.pzkagis.cz> (raw)
In-Reply-To: <4488B6EA.9050107@tpf.co.jp>
References: <20060607173910.GA28221@soptik.pzkagis.cz>
<4488B6EA.9050107@tpf.co.jp>
> > 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;
> }
>
> ...
I'm not sure. There are a lot of strcat, my_strcat, schema_strcat calls
between snprintf. There is only one place where snprintf could be called
after another snprintf.
BTW it's something what snprintf_addlen is doing. Or am I miss something?
I do the patch with minimal changes in mind. In my opinion strcat
may be faster in joining more char *.
Regards,
Luf
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: luf@pzkagis.cz, inoue@tpf.co.jp
Subject: Re: Patch for snprintf problem (bug #1000650)
In-Reply-To: <20060609081637.GA8153@soptik.pzkagis.cz>
References: <20060607173910.GA28221@soptik.pzkagis.cz> <4488B6EA.9050107@tpf.co.jp> <20060609081637.GA8153@soptik.pzkagis.cz>
* 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