pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc 7+ messages / 1 participants [nested] [flat]
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:18 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:18 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/3ff660bbeb96086cb1cf880bfb4e2e350cbd21b2 Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:19 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0dafed6fedf4da0e0e38c5961ae4b1540b4a8a5c Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:19 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9668bf5d5215cd4510c6cc9d1d07561b839b6a30 Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:19 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f71b22f537b987f6f4b04f889bbd955c548d7d72 Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:19 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c59414da7bd3be9f80e7585fc173d21942468d3b Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:20 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a17602de18f7ff7821054b3b7f51eadf9fb59d62 Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc @ 2019-11-30 14:20 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Tomas Vondra @ 2019-11-30 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d9b974e9947e54a9a55639f8f5f746bb5ad497b8 Modified Files -------------- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- .../ecpg/test/expected/pgtypeslib-dt_test.c | 24 ++++++++++++++++++---- .../ecpg/test/expected/pgtypeslib-dt_test.stderr | 2 +- .../ecpg/test/expected/pgtypeslib-dt_test.stdout | 2 ++ src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc | 16 +++++++++++++++ 5 files changed, 41 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2019-11-30 14:20 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-11-30 14:18 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org> 2019-11-30 14:19 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org> 2019-11-30 14:19 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org> 2019-11-30 14:19 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org> 2019-11-30 14:19 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org> 2019-11-30 14:20 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org> 2019-11-30 14:20 pgsql: Fix off-by-one error in PGTYPEStimestamp_fmt_asc Tomas Vondra <tomas.vondra@postgresql.org>
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