Adjust datetime parsing to be more robust. We now pass the length of the
Neil Conway <neilc@samurai.com>
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.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/date.c | modified | +10 −16 |
| src/backend/utils/adt/datetime.c | modified | +47 −30 |
| src/backend/utils/adt/nabstime.c | modified | +7 −11 |
| src/backend/utils/adt/timestamp.c | modified | +10 −16 |
| src/include/utils/datetime.h | modified | +2 −2 |
| src/test/regress/expected/interval.out | modified | +7 −0 |
| src/test/regress/sql/interval.sql | modified | +3 −0 |