git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: c41824c) | patch
Fix off-by-one error in PGTYPEStimestamp_fmt_asc
2019年11月30日 13:51:27 +0000 (14:51 +0100)
2019年11月30日 14:05:31 +0000 (15:05 +0100)
commit 9668bf5d5215cd4510c6cc9d1d07561b839b6a30
Fix off-by-one error in PGTYPEStimestamp_fmt_asc

When using %b or %B patterns to format a date, the code was simply using
tm_mon as an index into array of month names. But that is wrong, because
tm_mon is 1-based, while array indexes are 0-based. The result is we
either use name of the next month, or a segfault (for December).

Fix by subtracting 1 from tm_mon for both patterns, and add a regression
test triggering the issue. Backpatch to all supported versions (the bug
is there far longer, since at least 2003).

Reported-by: Paul Spencer
Backpatch-through: 9.4
Discussion: https://postgr.es/m/16143-0d861eb8688d3fef%40postgresql.org
src/interfaces/ecpg/pgtypeslib/timestamp.c diff | blob | blame | history
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c diff | blob | blame | history
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr diff | blob | blame | history
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stdout diff | blob | blame | history
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /