mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.211 2010/05/08 16:39:51 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.212 2010/05/09 02:15:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -3741,11 +3741,9 @@ EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style,
|
||||
AppendTimestampSeconds(str + strlen(str), tm, fsec);
|
||||
|
||||
/*
|
||||
* Note: the uses of %.*s in this function would be unportable
|
||||
* if the timezone names ever contain non-ASCII characters,
|
||||
* since some platforms think the string length is measured
|
||||
* in characters not bytes. However, all TZ abbreviations in
|
||||
* the Olson database are plain ASCII.
|
||||
* Note: the uses of %.*s in this function would be risky if the
|
||||
* timezone names ever contain non-ASCII characters. However, all
|
||||
* TZ abbreviations in the Olson database are plain ASCII.
|
||||
*/
|
||||
|
||||
if (tzp != NULL && tm->tm_isdst >= 0)
|
||||
|
Reference in New Issue
Block a user