pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix out-of-bound memory access for interval -> char conversion 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix out-of-bound memory access for interval -> char conversion @ 2021-04-12 02:32 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2021-04-12 02:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bound memory access for interval -> char conversion Using Roman numbers (via "RM" or "rm") for a conversion to calculate a number of months has never considered the case of negative numbers, where a conversion could easily cause out-of-bound memory accesses. The conversions in themselves were not completely consistent either, as specifying 12 would result in NULL, but it should mean XII. This commit reworks the conversion calculation to have a more consistent behavior: - If the number of months and years is 0, return NULL. - If the number of months is positive, return the exact month number. - If the number of months is negative, do a backward calculation, with -1 meaning December, -2 November, etc. Reported-by: Theodor Arsenij Larionov-Trichkin Author: Julien Rouhaud Discussion: https://postgr.es/m/16953-f255a18f8c51f1d5@postgresql.org backpatch-through: 9.6 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7a3972597f6ed7a6976d81abb66c38a7a1c29058 Modified Files -------------- src/backend/utils/adt/formatting.c | 63 +++++++++++++++++++++++++++------ src/test/regress/expected/timestamp.out | 36 +++++++++++++++++++ src/test/regress/sql/timestamp.sql | 6 ++++ 3 files changed, 95 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix out-of-bound memory access for interval -> char conversion @ 2021-04-12 02:32 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2021-04-12 02:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bound memory access for interval -> char conversion Using Roman numbers (via "RM" or "rm") for a conversion to calculate a number of months has never considered the case of negative numbers, where a conversion could easily cause out-of-bound memory accesses. The conversions in themselves were not completely consistent either, as specifying 12 would result in NULL, but it should mean XII. This commit reworks the conversion calculation to have a more consistent behavior: - If the number of months and years is 0, return NULL. - If the number of months is positive, return the exact month number. - If the number of months is negative, do a backward calculation, with -1 meaning December, -2 November, etc. Reported-by: Theodor Arsenij Larionov-Trichkin Author: Julien Rouhaud Discussion: https://postgr.es/m/16953-f255a18f8c51f1d5@postgresql.org backpatch-through: 9.6 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/be79debd9688da516f49ba9b825ee2e784d1fab0 Modified Files -------------- src/backend/utils/adt/formatting.c | 63 +++++++++++++++++++++++++++------ src/test/regress/expected/timestamp.out | 36 +++++++++++++++++++ src/test/regress/sql/timestamp.sql | 6 ++++ 3 files changed, 95 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix out-of-bound memory access for interval -> char conversion @ 2021-04-12 02:32 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2021-04-12 02:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bound memory access for interval -> char conversion Using Roman numbers (via "RM" or "rm") for a conversion to calculate a number of months has never considered the case of negative numbers, where a conversion could easily cause out-of-bound memory accesses. The conversions in themselves were not completely consistent either, as specifying 12 would result in NULL, but it should mean XII. This commit reworks the conversion calculation to have a more consistent behavior: - If the number of months and years is 0, return NULL. - If the number of months is positive, return the exact month number. - If the number of months is negative, do a backward calculation, with -1 meaning December, -2 November, etc. Reported-by: Theodor Arsenij Larionov-Trichkin Author: Julien Rouhaud Discussion: https://postgr.es/m/16953-f255a18f8c51f1d5@postgresql.org backpatch-through: 9.6 Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/82dd5706ee5a5fc4db962fe1a672b4f71ab51612 Modified Files -------------- src/backend/utils/adt/formatting.c | 63 +++++++++++++++++++++++++++------ src/test/regress/expected/timestamp.out | 36 +++++++++++++++++++ src/test/regress/sql/timestamp.sql | 6 ++++ 3 files changed, 95 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix out-of-bound memory access for interval -> char conversion @ 2021-04-12 02:32 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2021-04-12 02:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bound memory access for interval -> char conversion Using Roman numbers (via "RM" or "rm") for a conversion to calculate a number of months has never considered the case of negative numbers, where a conversion could easily cause out-of-bound memory accesses. The conversions in themselves were not completely consistent either, as specifying 12 would result in NULL, but it should mean XII. This commit reworks the conversion calculation to have a more consistent behavior: - If the number of months and years is 0, return NULL. - If the number of months is positive, return the exact month number. - If the number of months is negative, do a backward calculation, with -1 meaning December, -2 November, etc. Reported-by: Theodor Arsenij Larionov-Trichkin Author: Julien Rouhaud Discussion: https://postgr.es/m/16953-f255a18f8c51f1d5@postgresql.org backpatch-through: 9.6 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5656f2c3dce529b688eeeb2e98357c961376af80 Modified Files -------------- src/backend/utils/adt/formatting.c | 63 +++++++++++++++++++++++++++------ src/test/regress/expected/timestamp.out | 36 +++++++++++++++++++ src/test/regress/sql/timestamp.sql | 6 ++++ 3 files changed, 95 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix out-of-bound memory access for interval -> char conversion @ 2021-04-12 02:32 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2021-04-12 02:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bound memory access for interval -> char conversion Using Roman numbers (via "RM" or "rm") for a conversion to calculate a number of months has never considered the case of negative numbers, where a conversion could easily cause out-of-bound memory accesses. The conversions in themselves were not completely consistent either, as specifying 12 would result in NULL, but it should mean XII. This commit reworks the conversion calculation to have a more consistent behavior: - If the number of months and years is 0, return NULL. - If the number of months is positive, return the exact month number. - If the number of months is negative, do a backward calculation, with -1 meaning December, -2 November, etc. Reported-by: Theodor Arsenij Larionov-Trichkin Author: Julien Rouhaud Discussion: https://postgr.es/m/16953-f255a18f8c51f1d5@postgresql.org backpatch-through: 9.6 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1cc110f68dcca496c72292af2dba565f68932ae3 Modified Files -------------- src/backend/utils/adt/formatting.c | 63 +++++++++++++++++++++++++++------ src/test/regress/expected/timestamp.out | 36 +++++++++++++++++++ src/test/regress/sql/timestamp.sql | 6 ++++ 3 files changed, 95 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix out-of-bound memory access for interval -> char conversion @ 2021-04-12 02:32 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2021-04-12 02:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix out-of-bound memory access for interval -> char conversion Using Roman numbers (via "RM" or "rm") for a conversion to calculate a number of months has never considered the case of negative numbers, where a conversion could easily cause out-of-bound memory accesses. The conversions in themselves were not completely consistent either, as specifying 12 would result in NULL, but it should mean XII. This commit reworks the conversion calculation to have a more consistent behavior: - If the number of months and years is 0, return NULL. - If the number of months is positive, return the exact month number. - If the number of months is negative, do a backward calculation, with -1 meaning December, -2 November, etc. Reported-by: Theodor Arsenij Larionov-Trichkin Author: Julien Rouhaud Discussion: https://postgr.es/m/16953-f255a18f8c51f1d5@postgresql.org backpatch-through: 9.6 Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6540322fad8bc32e4d4eb38023d7b6cd8ef1b597 Modified Files -------------- src/backend/utils/adt/formatting.c | 63 +++++++++++++++++++++++++++------ src/test/regress/expected/timestamp.out | 36 +++++++++++++++++++ src/test/regress/sql/timestamp.sql | 6 ++++ 3 files changed, 95 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-04-12 02:32 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-04-12 02:32 pgsql: Fix out-of-bound memory access for interval -> char conversion Michael Paquier <michael@paquier.xyz> 2021-04-12 02:32 pgsql: Fix out-of-bound memory access for interval -> char conversion Michael Paquier <michael@paquier.xyz> 2021-04-12 02:32 pgsql: Fix out-of-bound memory access for interval -> char conversion Michael Paquier <michael@paquier.xyz> 2021-04-12 02:32 pgsql: Fix out-of-bound memory access for interval -> char conversion Michael Paquier <michael@paquier.xyz> 2021-04-12 02:32 pgsql: Fix out-of-bound memory access for interval -> char conversion Michael Paquier <michael@paquier.xyz> 2021-04-12 02:32 pgsql: Fix out-of-bound memory access for interval -> char conversion Michael Paquier <michael@paquier.xyz>
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