pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Replace static buf with a stack-allocated one in 'seg' extension
2+ messages / 1 participants
[nested] [flat]

* pgsql: Replace static buf with a stack-allocated one in 'seg' extension
@ 2024-07-30 19:24  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 2+ messages in thread

From: Heikki Linnakangas @ 2024-07-30 19:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Replace static buf with a stack-allocated one in ReadControlFile
@ 2024-07-30 19:24  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 2+ messages in thread

From: Heikki Linnakangas @ 2024-07-30 19:24 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Replace static buf with a stack-allocated one in ReadControlFile

It's only used very locally within the function.

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/da8a587e2e225be1ccf838a330e342bda6848874

Modified Files
--------------
src/backend/access/transam/xlog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-07-30 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-07-30 19:24 pgsql: Replace static buf with a stack-allocated one in ReadControlFile Heikki Linnakangas <heikki.linnakangas@iki.fi>
2024-07-30 19:24 pgsql: Replace static buf with a stack-allocated one in 'seg' extension Heikki Linnakangas <heikki.linnakangas@iki.fi>

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