pgsql: Adjust comments about avoiding use of printf's %.*s.

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Adjust comments about avoiding use of printf's %.*s.
Date: 2010-05-09 02:16:00
Message-ID: 20100509021600.6BCBB7541D2@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Adjust comments about avoiding use of printf's %.*s.
My initial impression that glibc was measuring the precision in characters
(which is what the Linux man page says it does) was incorrect. It does take
the precision to be in bytes, but it also tries to truncate the string at a
character boundary. The bottom line remains the same: it will mess up
if the string is not in the encoding it expects, so we need to avoid %.*s
anytime there's a significant risk of that. Previous code changes are still
good, but adjust the comments to reflect this knowledge. Per research by
Hernan Gonzalez.

Modified Files:
--------------
pgsql/src/backend/parser:
scansup.c (r1.40 -> r1.41)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/scansup.c?r1=1.40&r2=1.41)
pgsql/src/backend/tsearch:
wparser_def.c (r1.31 -> r1.32)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/wparser_def.c?r1=1.31&r2=1.32)
pgsql/src/backend/utils/adt:
datetime.c (r1.211 -> r1.212)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/datetime.c?r1=1.211&r2=1.212)
pgsql/src/bin/psql:
print.c (r1.125 -> r1.126)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/print.c?r1=1.125&r2=1.126)
pgsql/src/interfaces/ecpg/pgtypeslib:
dt_common.c (r1.52 -> r1.53)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c?r1=1.52&r2=1.53)
pgsql/src/interfaces/libpq:
fe-misc.c (r1.142 -> r1.143)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-misc.c?r1=1.142&r2=1.143)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-05-09 16:30:31 pgsql: Fix typo: PGTYPES_NUM_OVERFLOW should be PGTYPES_NUM_UNDERFLOW.
Previous Message Tom Lane 2010-05-08 16:40:52 pgsql: Work around a subtle portability problem in use of printf %s