pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Daniel Gustafsson <daniel@yesql.se>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: David Steele <david@pgmasters.net>
Cc: Cary Huang <cary.huang@highgo.ca>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: pg_rewind copies
Date: Mon, 4 Apr 2022 15:08:12 +0200
Message-ID: <97e6edb1-0f9a-685a-c860-0d886d8f94ba@enterprisedb.com> (raw)
In-Reply-To: <FBE3D7A0-4291-40F1-B4B7-637A440686C7@yesql.se>
References: <f67feb24-5833-88cb-1020-19a4a2b83ac7@iki.fi>
	<f67feb24-5833-88cb-1020-19a4a2b83ac7@iki.fi>
	<160807013024.1158.705820212542993455.pgcf@coridan.postgresql.org>
	<b2ebc855-61e3-818b-d6b8-cddf3e3d8816@iki.fi>
	<171fd136-d523-57fd-6f03-26eea9427136@pgmasters.net>
	<AF289C6A-109F-4B48-A27C-67264A4636B3@yesql.se>
	<FBE3D7A0-4291-40F1-B4B7-637A440686C7@yesql.se>

On 01.04.22 11:00, Daniel Gustafsson wrote:
> One small comment on the patch:
> 
> +   snprintf(srcpath, sizeof(srcpath), "%s/%s", datadir, path);
> 
> This should IMO check the returnvalue of snprintf to ensure it wasn't
> truncated.  While the risk is exceedingly small, a truncated filename might
> match another existing filename and the error not getting caught.  There is
> another instance just like this one in open_target_file() to which I think we
> should apply the same belts-and-suspenders treatment.  I've fixed this in the
> attached version which also have had a pg_indent run on top of a fresh rebase.

We use snprintf() like that countless times, and approximately none of 
them check for overflow.  So while you are right, this might not be the 
place to start a new policy.

If you don't like this approach, use psprintf() perhaps.





view thread (10+ messages)  latest in thread

Message-ID: <97e6edb1-0f9a-685a-c860-0d886d8f94ba@enterprisedb.com>
Permalink:  ../97e6edb1-0f9a-685a-c860-0d886d8f94ba@enterprisedb.com/
Also on:    postgresql.org/message-id/97e6edb1-0f9a-685a-c860-0d886d8f94ba@enterprisedb.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@enterprisedb.com, daniel@yesql.se, hlinnaka@iki.fi, david@pgmasters.net, cary.huang@highgo.ca, pgsql-hackers@lists.postgresql.org
  Subject: Re: pg_rewind copies
  In-Reply-To: <97e6edb1-0f9a-685a-c860-0d886d8f94ba@enterprisedb.com>

* 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