pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Page <dpage@vale-housing.co.uk>
Cc: pgsql-odbc@postgresql.org
Cc: Didier Moens <moensd@xs4all.be>
Subject: Re: SQLGetInfo Bug
Date: Thu, 02 Jan 2003 10:03:12 -0500
Message-ID: <20229.1041519792@sss.pgh.pa.us> (raw)
In-Reply-To: <03AF4E498C591348A42FC93DEA9661B88547@mail.vale-housing.co.uk>
References: <03AF4E498C591348A42FC93DEA9661B88547@mail.vale-housing.co.uk>

"Dave Page" <dpage@vale-housing.co.uk> writes:
> The garbage is not there if I use sprintf with a larger size of
> tmp. I've tried variations of the code to check (without luck) but I
> assume I'm not somehow knocking the null off the end of the string?

You would be losing the trailing null if the snprintf is unable to fit
its output into the buffer size it's told to use (at least, that's how
most implementations of snprintf react, I think).

It doesn't look like this should be enough data to overrun your buffer,
but I don't have a better theory at the moment.

Perhaps

	snprintf(tmp, sizeof(tmp) - 1, "%s %s", ...);
	tmp[sizeof(tmp) - 1] = '\0';

would be better coding practice if you don't want to actually check
snprintf's result.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <20229.1041519792@sss.pgh.pa.us>
Permalink:  ../20229.1041519792@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20229.1041519792@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, dpage@vale-housing.co.uk, moensd@xs4all.be
  Subject: Re: SQLGetInfo Bug
  In-Reply-To: <20229.1041519792@sss.pgh.pa.us>
  References: <03AF4E498C591348A42FC93DEA9661B88547@mail.vale-housing.co.uk> <20229.1041519792@sss.pgh.pa.us>

* 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