pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Replace static buf with a stack-allocated one in 'seg' extension
Date: Tue, 30 Jul 2024 19:24:48 +0000
Message-ID: <E1sYsSm-001vmA-1f@gemulon.postgresql.org> (raw)

Replace static buf with a stack-allocated one in 'seg' extension

The buffer is used only locally within the function. Also, the
initialization to '0' characters was unnecessary, the initial content
were always overwritten with sprintf(). I don't understand why it was
done that way, but it's been like that since forever.

In the passing, change from sprintf() to snprintf(). The buffer was
long enough so sprintf() was fine, but this makes it more obvious that
there's no risk of a buffer overflow.

Reviewed-by: Robert Haas
Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5-4ce3-8ec9-3885c8de0358@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/01e51ed78070703c7e078f1519ad59af38e2888a

Modified Files
--------------
contrib/seg/segparse.y | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1sYsSm-001vmA-1f@gemulon.postgresql.org>
Permalink:  ../E1sYsSm-001vmA-1f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sYsSm-001vmA-1f@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Replace static buf with a stack-allocated one in 'seg' extension
  In-Reply-To: <E1sYsSm-001vmA-1f@gemulon.postgresql.org>

* 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