aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/backend_random.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-04-12 11:31:35 +0900
committerMichael Paquier <michael@paquier.xyz>2021-04-12 11:31:35 +0900
commit5656f2c3dce529b688eeeb2e98357c961376af80 (patch)
tree09ea260f1e2f2fd11821a62fae5d777b093522c9 /src/backend/utils/misc/backend_random.c
parent721b3a3a9368c0bd5e9b92892279f0fa441efeee (diff)
downloadpostgresql-5656f2c3dce529b688eeeb2e98357c961376af80.tar.gz
postgresql-5656f2c3dce529b688eeeb2e98357c961376af80.zip
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
Diffstat (limited to 'src/backend/utils/misc/backend_random.c')
0 files changed, 0 insertions, 0 deletions