pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf.
5+ messages / 1 participants
[nested] [flat]

* pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf.
@ 2022-10-16 15:48 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 15:48 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use libc's snprintf, not sprintf, for special cases in snprintf.c.

snprintf.c has always fallen back on libc's *printf implementation
when printing pointers (%p) and floats.  When this code originated,
we were still supporting some platforms that lacked native snprintf,
so we used sprintf for that.  That's not actually unsafe in our usage,
but nonetheless builds on macOS are starting to complain about sprintf
being unconditionally deprecated; and I wouldn't be surprised if other
platforms follow suit.  There seems little reason to believe that any
platform supporting C99 wouldn't have standards-compliant snprintf,
so let's just use that instead to suppress such warnings.

Back-patch to v12, which is where we started to require C99.  It's
also where we started to use our snprintf.c everywhere, so this
wouldn't be enough to suppress the warning in older branches anyway
--- that is, in older branches these aren't necessarily all our
usages of libc's sprintf.  It is enough in v12+ because any
deprecation annotation attached to libc's sprintf won't apply to
pg_sprintf.  (Whether all our usages of pg_sprintf are adequately
safe is not a matter I intend to address here, but perhaps it could
do with some review.)

Per report from Andres Freund and local testing.

Discussion: https://postgr.es/m/20221015211955.q4cwbsfkyk3c4ty3@awork3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/450ee701261a7ff5fe35842b91384eea46e81c2e

Modified Files
--------------
src/port/snprintf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)



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

* pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf.
@ 2022-10-16 15:48 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 15:48 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use libc's snprintf, not sprintf, for special cases in snprintf.c.

snprintf.c has always fallen back on libc's *printf implementation
when printing pointers (%p) and floats.  When this code originated,
we were still supporting some platforms that lacked native snprintf,
so we used sprintf for that.  That's not actually unsafe in our usage,
but nonetheless builds on macOS are starting to complain about sprintf
being unconditionally deprecated; and I wouldn't be surprised if other
platforms follow suit.  There seems little reason to believe that any
platform supporting C99 wouldn't have standards-compliant snprintf,
so let's just use that instead to suppress such warnings.

Back-patch to v12, which is where we started to require C99.  It's
also where we started to use our snprintf.c everywhere, so this
wouldn't be enough to suppress the warning in older branches anyway
--- that is, in older branches these aren't necessarily all our
usages of libc's sprintf.  It is enough in v12+ because any
deprecation annotation attached to libc's sprintf won't apply to
pg_sprintf.  (Whether all our usages of pg_sprintf are adequately
safe is not a matter I intend to address here, but perhaps it could
do with some review.)

Per report from Andres Freund and local testing.

Discussion: https://postgr.es/m/20221015211955.q4cwbsfkyk3c4ty3@awork3.anarazel.de

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bd4b2926ecc25b4435f816ce4ec542d9a01cdb09

Modified Files
--------------
src/port/snprintf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)



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

* pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf.
@ 2022-10-16 15:48 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 15:48 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use libc's snprintf, not sprintf, for special cases in snprintf.c.

snprintf.c has always fallen back on libc's *printf implementation
when printing pointers (%p) and floats.  When this code originated,
we were still supporting some platforms that lacked native snprintf,
so we used sprintf for that.  That's not actually unsafe in our usage,
but nonetheless builds on macOS are starting to complain about sprintf
being unconditionally deprecated; and I wouldn't be surprised if other
platforms follow suit.  There seems little reason to believe that any
platform supporting C99 wouldn't have standards-compliant snprintf,
so let's just use that instead to suppress such warnings.

Back-patch to v12, which is where we started to require C99.  It's
also where we started to use our snprintf.c everywhere, so this
wouldn't be enough to suppress the warning in older branches anyway
--- that is, in older branches these aren't necessarily all our
usages of libc's sprintf.  It is enough in v12+ because any
deprecation annotation attached to libc's sprintf won't apply to
pg_sprintf.  (Whether all our usages of pg_sprintf are adequately
safe is not a matter I intend to address here, but perhaps it could
do with some review.)

Per report from Andres Freund and local testing.

Discussion: https://postgr.es/m/20221015211955.q4cwbsfkyk3c4ty3@awork3.anarazel.de

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6fa431d84a046603ec7c2d54ad51955487686b20

Modified Files
--------------
src/port/snprintf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)



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

* pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf.
@ 2022-10-16 15:48 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 15:48 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use libc's snprintf, not sprintf, for special cases in snprintf.c.

snprintf.c has always fallen back on libc's *printf implementation
when printing pointers (%p) and floats.  When this code originated,
we were still supporting some platforms that lacked native snprintf,
so we used sprintf for that.  That's not actually unsafe in our usage,
but nonetheless builds on macOS are starting to complain about sprintf
being unconditionally deprecated; and I wouldn't be surprised if other
platforms follow suit.  There seems little reason to believe that any
platform supporting C99 wouldn't have standards-compliant snprintf,
so let's just use that instead to suppress such warnings.

Back-patch to v12, which is where we started to require C99.  It's
also where we started to use our snprintf.c everywhere, so this
wouldn't be enough to suppress the warning in older branches anyway
--- that is, in older branches these aren't necessarily all our
usages of libc's sprintf.  It is enough in v12+ because any
deprecation annotation attached to libc's sprintf won't apply to
pg_sprintf.  (Whether all our usages of pg_sprintf are adequately
safe is not a matter I intend to address here, but perhaps it could
do with some review.)

Per report from Andres Freund and local testing.

Discussion: https://postgr.es/m/20221015211955.q4cwbsfkyk3c4ty3@awork3.anarazel.de

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a2acafc7be7a957e72234bb28b83a5e4d2bc019f

Modified Files
--------------
src/port/snprintf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)



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

* pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf.
@ 2022-10-16 15:48 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2022-10-16 15:48 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use libc's snprintf, not sprintf, for special cases in snprintf.c.

snprintf.c has always fallen back on libc's *printf implementation
when printing pointers (%p) and floats.  When this code originated,
we were still supporting some platforms that lacked native snprintf,
so we used sprintf for that.  That's not actually unsafe in our usage,
but nonetheless builds on macOS are starting to complain about sprintf
being unconditionally deprecated; and I wouldn't be surprised if other
platforms follow suit.  There seems little reason to believe that any
platform supporting C99 wouldn't have standards-compliant snprintf,
so let's just use that instead to suppress such warnings.

Back-patch to v12, which is where we started to require C99.  It's
also where we started to use our snprintf.c everywhere, so this
wouldn't be enough to suppress the warning in older branches anyway
--- that is, in older branches these aren't necessarily all our
usages of libc's sprintf.  It is enough in v12+ because any
deprecation annotation attached to libc's sprintf won't apply to
pg_sprintf.  (Whether all our usages of pg_sprintf are adequately
safe is not a matter I intend to address here, but perhaps it could
do with some review.)

Per report from Andres Freund and local testing.

Discussion: https://postgr.es/m/20221015211955.q4cwbsfkyk3c4ty3@awork3.anarazel.de

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d33ac1ec2af5297b2ac8fbf89464f0c7f90a7955

Modified Files
--------------
src/port/snprintf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)



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


end of thread, other threads:[~2022-10-16 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 15:48 pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf. Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 15:48 pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf. Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 15:48 pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf. Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 15:48 pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf. Tom Lane <tgl@sss.pgh.pa.us>
2022-10-16 15:48 pgsql: Use libc's snprintf, not sprintf, for special cases in snprintf. Tom Lane <tgl@sss.pgh.pa.us>

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