pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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) 3-rd try
Date: Fri, 9 Jun 2006 14:13:23 +0200
Message-ID: <20060609121323.GA17258@soptik.pzkagis.cz> (raw)
In-Reply-To: <20060609081637.GA8153@soptik.pzkagis.cz>
References: <20060607173910.GA28221@soptik.pzkagis.cz>
	<4488B6EA.9050107@tpf.co.jp>
	<20060609081637.GA8153@soptik.pzkagis.cz>

> > > 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.

I change the snprintf_addlen to snprintf_len as you mentioned.

Third try of patch attached.

Comments are welcome

Luf



view thread (2+ messages)  latest in thread

Message-ID: <20060609121323.GA17258@soptik.pzkagis.cz>
Permalink:  ../20060609121323.GA17258@soptik.pzkagis.cz/
Also on:    postgresql.org/message-id/20060609121323.GA17258@soptik.pzkagis.cz

 · 

reply

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) 3-rd try
  In-Reply-To: <20060609121323.GA17258@soptik.pzkagis.cz>
  References: <20060607173910.GA28221@soptik.pzkagis.cz> <4488B6EA.9050107@tpf.co.jp> <20060609081637.GA8153@soptik.pzkagis.cz> <20060609121323.GA17258@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