mirror of
https://github.com/postgres/postgres.git
synced 2025-12-15 02:22:24 +03:00
Adjust datetime parsing to be more robust. We now pass the length of the
working buffer into ParseDateTime() and reject too-long input there, rather than checking the length of the input string before calling ParseDateTime(). The old method was bogus because ParseDateTime() can use a variable amount of working space, depending on the content of the input string (e.g. how many fields need to be NUL terminated). This fixes a minor stack overrun -- I don't _think_ it's exploitable, although I won't claim to be an expert. Along the way, fix a bug reported by Mark Dilger: the working buffer allocated by interval_in() was too short, which resulted in rejecting some perfectly valid interval input values. I added a regression test for this fix.
This commit is contained in:
@@ -221,3 +221,10 @@ select avg(f1) from interval_tbl;
|
||||
@ 4 years 1 mon 10 days 4 hours 18 mins 23 secs
|
||||
(1 row)
|
||||
|
||||
-- test long interval input
|
||||
select '4 millenniums 5 centuries 4 decades 1 year 4 months 4 days 17 minutes 31 seconds'::interval;
|
||||
interval
|
||||
--------------------------------------------
|
||||
@ 4541 years 4 mons 4 days 17 mins 31 secs
|
||||
(1 row)
|
||||
|
||||
|
||||
@@ -66,3 +66,6 @@ SELECT '' AS ten, * FROM INTERVAL_TBL;
|
||||
-- updating pg_aggregate.agginitval
|
||||
|
||||
select avg(f1) from interval_tbl;
|
||||
|
||||
-- test long interval input
|
||||
select '4 millenniums 5 centuries 4 decades 1 year 4 months 4 days 17 minutes 31 seconds'::interval;
|
||||
|
||||
Reference in New Issue
Block a user