pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16953: OOB access while converting "interval" to char
9+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2021-04-12 7a3972597f be79debd96 82dd5706ee 5656f2c3dc 1cc110f68d 6540322fad Fix out-of-bound memory access for interval -> char conversion
* BUG #16953: OOB access while converting "interval" to char
@ 2021-04-07 09:09 PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: PG Bug reporting form @ 2021-04-07 09:09 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: t.larionov@postgrespro.ru
The following bug has been logged on the website:
Bug reference: 16953
Logged by: Theodor Arsenij Larionov-Trichkin
Email address: t.larionov@postgrespro.ru
PostgreSQL version: 13.2
Operating system: Ubuntu 20.04.2 LTS
Description:
Hello!
How to reproduce:
1. mkdir -p ./installation/databases
2. git clone --single-branch --depth=1 --branch=REL_13_2
https://github.com/postgres/postgres postgres_src
3. cd postgres_src
4. ./configure --prefix=`pwd`/../installation/pgbuild
5. make -j20 && make install && cd ..
6. ./installation/pgbuild/bin/initdb -U username -D
./installation/databases/db_clean
7. ./installation/pgbuild/bin/postgres -D
./installation/databases/db_clean/
8. ./installation/pgbuild/bin/psql -h 127.0.0.1 -p 5432 -U username
postgres
9. Performing this query will result in OOB access of rm_months_lower array
and as a result crash: SELECT * from TO_CHAR(interval '-1Mon', 'rm');
Output:
2021-04-07 12:07:27.060 MSK [33887] LOG: starting PostgreSQL 13.2 on
x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0,
64-bit
2021-04-07 12:07:27.060 MSK [33887] LOG: listening on IPv4 address
"127.0.0.1", port 5432
2021-04-07 12:07:27.065 MSK [33887] LOG: listening on Unix socket
"/tmp/.s.PGSQL.5432"
2021-04-07 12:07:27.069 MSK [33888] LOG: database system was shut down at
2021-04-07 12:07:22 MSK
2021-04-07 12:07:27.071 MSK [33887] LOG: database system is ready to accept
connections
2021-04-07 12:08:01.013 MSK [33887] LOG: server process (PID 34113) was
terminated by signal 11: Segmentation fault
2021-04-07 12:08:01.013 MSK [33887] DETAIL: Failed process was running:
SELECT * from TO_CHAR(interval '-1Mon', 'rm');
2021-04-07 12:08:01.013 MSK [33887] LOG: terminating any other active
server processes
2021-04-07 12:08:01.013 MSK [33892] WARNING: terminating connection because
of crash of another server process
2021-04-07 12:08:01.013 MSK [33892] DETAIL: The postmaster has commanded
this server process to roll back the current transaction and exit, because
another server process exited abnormally and possibly corrupted shared
memory.
2021-04-07 12:08:01.013 MSK [33892] HINT: In a moment you should be able to
reconnect to the database and repeat your command.
2021-04-07 12:08:01.013 MSK [35036] FATAL: the database system is in
recovery mode
2021-04-07 12:08:01.014 MSK [33887] LOG: all server processes terminated;
reinitializing
2021-04-07 12:08:01.027 MSK [35038] LOG: database system was interrupted;
last known up at 2021-04-07 12:07:27 MSK
2021-04-07 12:08:01.248 MSK [35038] LOG: database system was not properly
shut down; automatic recovery in progress
2021-04-07 12:08:01.249 MSK [35038] LOG: redo starts at 0/1559798
2021-04-07 12:08:01.249 MSK [35038] LOG: invalid record length at
0/15597D0: wanted 24, got 0
2021-04-07 12:08:01.249 MSK [35038] LOG: redo done at 0/1559798
2021-04-07 12:08:01.256 MSK [33887] LOG: database system is ready to accept
connections
Postgres version:
PostgreSQL 13.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
@ 2021-04-07 12:08 ` Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Julien Rouhaud @ 2021-04-07 12:08 UTC (permalink / raw)
To: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
Hi,
On Wed, Apr 07, 2021 at 09:09:25AM +0000, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 16953
> Logged by: Theodor Arsenij Larionov-Trichkin
> Email address: t.larionov@postgrespro.ru
> PostgreSQL version: 13.2
> Operating system: Ubuntu 20.04.2 LTS
> Description:
>
> 9. Performing this query will result in OOB access of rm_months_lower array
> and as a result crash: SELECT * from TO_CHAR(interval '-1Mon', 'rm');
>
> Output:
> [...]
> terminated by signal 11: Segmentation fault
> 2021-04-07 12:08:01.013 MSK [33887] DETAIL: Failed process was running:
> SELECT * from TO_CHAR(interval '-1Mon', 'rm');
Indeed, thanks a lot for the report!
It's because rm/RM are computed in a way that doesn't play nice with negative
values:
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
rm_months_lower[MONTHS_PER_YEAR - tm->tm_mon]);
PFA a naive patch to fix this problem with some regression tests. I'm assuming
that -1 month should be january and not december. I had a quick look at the
rest of formatting.c and didn't spot any similar problem, but another pair of
eyes wouldn't hurt.
Attachments:
v1-fix_rm.diff (text/plain, 2.0K) download
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 783c7b5e7a..9e64eec7da 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -3210,14 +3210,14 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
if (!tm->tm_mon)
break;
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
- rm_months_upper[MONTHS_PER_YEAR - tm->tm_mon]);
+ rm_months_upper[MONTHS_PER_YEAR - Abs(tm->tm_mon)]);
s += strlen(s);
break;
case DCH_rm:
if (!tm->tm_mon)
break;
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
- rm_months_lower[MONTHS_PER_YEAR - tm->tm_mon]);
+ rm_months_lower[MONTHS_PER_YEAR - Abs(tm->tm_mon)]);
s += strlen(s);
break;
case DCH_W:
diff --git a/src/test/regress/expected/timestamp.out b/src/test/regress/expected/timestamp.out
index fff3cf08c1..2ef529dd28 100644
--- a/src/test/regress/expected/timestamp.out
+++ b/src/test/regress/expected/timestamp.out
@@ -1816,6 +1816,18 @@ SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US')
7 78 789 7890 78901 789012 7 78 789 7890 78901 789012 789 789012
(4 rows)
+SELECT to_char(interval '-3mon', 'rm');
+ to_char
+---------
+ iii
+(1 row)
+
+SELECT to_char(interval '-1year -10mon', 'RM');
+ to_char
+---------
+ X
+(1 row)
+
-- timestamp numeric fields constructor
SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887);
make_timestamp
diff --git a/src/test/regress/sql/timestamp.sql b/src/test/regress/sql/timestamp.sql
index ed03d7c218..fddf553e2b 100644
--- a/src/test/regress/sql/timestamp.sql
+++ b/src/test/regress/sql/timestamp.sql
@@ -306,6 +306,10 @@ SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US')
('2018-11-02 12:34:56.78901234')
) d(d);
+SELECT to_char(interval '-3mon', 'rm');
+
+SELECT to_char(interval '-1year -10mon', 'RM');
+
-- timestamp numeric fields constructor
SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887);
SELECT make_timestamp(-44, 3, 15, 12, 30, 15);
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
@ 2021-04-08 10:17 ` Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2021-04-08 10:17 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Wed, Apr 07, 2021 at 08:08:56PM +0800, Julien Rouhaud wrote:
> PFA a naive patch to fix this problem with some regression tests. I'm assuming
> that -1 month should be january and not december. I had a quick look at the
> rest of formatting.c and didn't spot any similar problem, but another pair of
> eyes wouldn't hurt.
Assuming an absolute number is not really intuitive when it comes to a
negative number here, while counting backward feels more natural, so I
would vote for making -1 be December, -2 November, etc.
Let's also make the tests more extended. I would suggest a single
query with generate_series() from say -12 to 12, that checks the
output of both RM and rm for the full range of values supported by
tm_mon.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
@ 2021-04-08 11:04 ` Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 11:37 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Julien Rouhaud @ 2021-04-08 11:04 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Thu, Apr 08, 2021 at 07:17:50PM +0900, Michael Paquier wrote:
> On Wed, Apr 07, 2021 at 08:08:56PM +0800, Julien Rouhaud wrote:
> > PFA a naive patch to fix this problem with some regression tests. I'm assuming
> > that -1 month should be january and not december. I had a quick look at the
> > rest of formatting.c and didn't spot any similar problem, but another pair of
> > eyes wouldn't hurt.
>
> Assuming an absolute number is not really intuitive when it comes to a
> negative number here, while counting backward feels more natural, so I
> would vote for making -1 be December, -2 November, etc.
Honestly I might as well have flipped a coin here, so I'm fine either way.
> Let's also make the tests more extended. I would suggest a single
> query with generate_series() from say -12 to 12, that checks the
> output of both RM and rm for the full range of values supported by
> tm_mon.
I'm fine with it too, although I'd probably go with [-13, 13] just to make sure
that there's isn't silly off-by-one mistake.
I'll just wait a bit to see if anyone else has any opinion on whether -1 month
should be January or December.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
@ 2021-04-08 11:37 ` Michael Paquier <michael@paquier.xyz>
2021-04-09 10:42 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2021-04-08 11:37 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Thu, Apr 08, 2021 at 07:04:03PM +0800, Julien Rouhaud wrote:
> I'm fine with it too, although I'd probably go with [-13, 13] just to make sure
> that there's isn't silly off-by-one mistake.
Also, I guess that you'd just want to compile twice a modulo based on
MONTHS_PER_YEAR to get the correct positive position in each array.
> I'll just wait a bit to see if anyone else has any opinion on whether -1 month
> should be January or December.
Sure. If you can send an updated patch, that would be great.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 11:37 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
@ 2021-04-09 10:42 ` Julien Rouhaud <rjuju123@gmail.com>
2021-04-09 10:58 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Julien Rouhaud @ 2021-04-09 10:42 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Thu, Apr 08, 2021 at 08:37:21PM +0900, Michael Paquier wrote:
> On Thu, Apr 08, 2021 at 07:04:03PM +0800, Julien Rouhaud wrote:
> > I'm fine with it too, although I'd probably go with [-13, 13] just to make sure
> > that there's isn't silly off-by-one mistake.
>
> Also, I guess that you'd just want to compile twice a modulo based on
> MONTHS_PER_YEAR to get the correct positive position in each array.
I'm not sure what you mean by that. We receive a pg_tm struct which can't
contain more than 12 in tm_mon right? And actually for intervals it will
reduce "12 months" to "1 year 0 month", so to_char previously didn't report
anything for 12 months either.
>
> > I'll just wait a bit to see if anyone else has any opinion on whether -1 month
> > should be January or December.
>
> Sure. If you can send an updated patch, that would be great.
Hearing no other opinion I went with -1 -> december and so on in attached v2.
I also fixed the "[-]12 months" case and updated the regression tests. Given
the extra code needed to deduce the correct array position I factorized DCH_RM
and DCH_rm.
Attachments:
v2-fix_rm.diff (text/plain, 3.4K) download
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 783c7b5e7a..80138d6347 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -3207,18 +3207,36 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
s += strlen(s);
break;
case DCH_RM:
- if (!tm->tm_mon)
- break;
- sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
- rm_months_upper[MONTHS_PER_YEAR - tm->tm_mon]);
- s += strlen(s);
- break;
+ /* FALLTHROUGH */
case DCH_rm:
- if (!tm->tm_mon)
+ /*
+ * For intervals, values like '12 month' will be reduced to 0
+ * month and some years, which we want to process.
+ */
+ if (!tm->tm_mon && !tm->tm_year)
break;
- sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
- rm_months_lower[MONTHS_PER_YEAR - tm->tm_mon]);
- s += strlen(s);
+ else
+ {
+ int mon = tm->tm_mon;
+ const char * const* months;
+
+ if (n->key->id == DCH_RM)
+ months = rm_months_upper;
+ else
+ months = rm_months_lower;
+
+ if (mon == 0)
+ {
+ Assert(is_interval);
+ mon = tm->tm_year >= 0 ? MONTHS_PER_YEAR : 1;
+ }
+ else if (mon < 0)
+ mon = MONTHS_PER_YEAR + mon + 1;
+
+ sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -4,
+ months[MONTHS_PER_YEAR - mon]);
+ s += strlen(s);
+ }
break;
case DCH_W:
sprintf(s, "%d", (tm->tm_mday - 1) / 7 + 1);
diff --git a/src/test/regress/expected/timestamp.out b/src/test/regress/expected/timestamp.out
index 690656dfb2..7c77fcae71 100644
--- a/src/test/regress/expected/timestamp.out
+++ b/src/test/regress/expected/timestamp.out
@@ -1907,6 +1907,39 @@ SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US')
7 78 789 7890 78901 789012 7 78 789 7890 78901 789012 789 789012
(4 rows)
+SELECT i, to_char(i * interval '1mon', 'rm'), to_char(i * interval '1mon', 'RM')
+ FROM generate_series(-13, 13) i;
+ i | to_char | to_char
+-----+---------+---------
+ -13 | xii | XII
+ -12 | i | I
+ -11 | ii | II
+ -10 | iii | III
+ -9 | iv | IV
+ -8 | v | V
+ -7 | vi | VI
+ -6 | vii | VII
+ -5 | viii | VIII
+ -4 | ix | IX
+ -3 | x | X
+ -2 | xi | XI
+ -1 | xii | XII
+ 0 | |
+ 1 | i | I
+ 2 | ii | II
+ 3 | iii | III
+ 4 | iv | IV
+ 5 | v | V
+ 6 | vi | VI
+ 7 | vii | VII
+ 8 | viii | VIII
+ 9 | ix | IX
+ 10 | x | X
+ 11 | xi | XI
+ 12 | xii | XII
+ 13 | i | I
+(27 rows)
+
-- timestamp numeric fields constructor
SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887);
make_timestamp
diff --git a/src/test/regress/sql/timestamp.sql b/src/test/regress/sql/timestamp.sql
index c43a1f2268..3ae9a52347 100644
--- a/src/test/regress/sql/timestamp.sql
+++ b/src/test/regress/sql/timestamp.sql
@@ -319,6 +319,9 @@ SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US')
('2018-11-02 12:34:56.78901234')
) d(d);
+SELECT i, to_char(i * interval '1mon', 'rm'), to_char(i * interval '1mon', 'RM')
+ FROM generate_series(-13, 13) i;
+
-- timestamp numeric fields constructor
SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887);
SELECT make_timestamp(-44, 3, 15, 12, 30, 15);
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 11:37 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-09 10:42 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
@ 2021-04-09 10:58 ` Michael Paquier <michael@paquier.xyz>
2021-04-12 03:04 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2021-04-09 10:58 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Fri, Apr 09, 2021 at 06:42:46PM +0800, Julien Rouhaud wrote:
> I'm not sure what you mean by that. We receive a pg_tm struct which can't
> contain more than 12 in tm_mon right? And actually for intervals it will
> reduce "12 months" to "1 year 0 month", so to_char previously didn't report
> anything for 12 months either.
I did not take the time to look in details, but for reference I just
imagined that a formula like this one would give pretty much the
position in rm_months_upper:
M_PER_Y - ((tm_mon % M_PER_Y) + M_PER_Y) % M_PER_Y
> Hearing no other opinion I went with -1 -> december and so on in attached v2.
> I also fixed the "[-]12 months" case and updated the regression tests. Given
> the extra code needed to deduce the correct array position I factorized DCH_RM
> and DCH_rm.
Yep. The regression tests show what I would expect. I'll check in
details later.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 11:37 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-09 10:42 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-09 10:58 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
@ 2021-04-12 03:04 ` Michael Paquier <michael@paquier.xyz>
2021-04-12 03:13 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2021-04-12 03:04 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Fri, Apr 09, 2021 at 07:58:51PM +0900, Michael Paquier wrote:
> Yep. The regression tests show what I would expect. I'll check in
> details later.
I have spent some time on that today and applied this patch down to
9.6, after adding more comments and simplifying a bit the calculation
method used. Instead of using the "mon" variable to store an
intermediate result, I have simplified things so as this only uses
tm->tm_mon, and "mon" for the position in the roman-numeral array is
adjusted only once.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: BUG #16953: OOB access while converting "interval" to char
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 11:37 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-09 10:42 ` Re: BUG #16953: OOB access while converting "interval" to char Julien Rouhaud <rjuju123@gmail.com>
2021-04-09 10:58 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
2021-04-12 03:04 ` Re: BUG #16953: OOB access while converting "interval" to char Michael Paquier <michael@paquier.xyz>
@ 2021-04-12 03:13 ` Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Julien Rouhaud @ 2021-04-12 03:13 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: t.larionov@postgrespro.ru; pgsql-bugs@lists.postgresql.org
On Mon, Apr 12, 2021 at 12:04:23PM +0900, Michael Paquier wrote:
> On Fri, Apr 09, 2021 at 07:58:51PM +0900, Michael Paquier wrote:
> > Yep. The regression tests show what I would expect. I'll check in
> > details later.
>
> I have spent some time on that today and applied this patch down to
> 9.6, after adding more comments and simplifying a bit the calculation
> method used. Instead of using the "mon" variable to store an
> intermediate result, I have simplified things so as this only uses
> tm->tm_mon, and "mon" for the position in the roman-numeral array is
> adjusted only once.
Thanks Michael! I thought we'd want to keep the original calculation for
consistency, but directly computing the needed offset is clearly simpler to
read!
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2021-04-12 03:13 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 09:09 BUG #16953: OOB access while converting "interval" to char PG Bug reporting form <noreply@postgresql.org>
2021-04-07 12:08 ` Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 10:17 ` Michael Paquier <michael@paquier.xyz>
2021-04-08 11:04 ` Julien Rouhaud <rjuju123@gmail.com>
2021-04-08 11:37 ` Michael Paquier <michael@paquier.xyz>
2021-04-09 10:42 ` Julien Rouhaud <rjuju123@gmail.com>
2021-04-09 10:58 ` Michael Paquier <michael@paquier.xyz>
2021-04-12 03:04 ` Michael Paquier <michael@paquier.xyz>
2021-04-12 03:13 ` Julien Rouhaud <rjuju123@gmail.com>
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