A single character following NOW, TODAY, TOMORROW or YESTERDAY is silently ignored instead of raising a conversion error:
SELECT CAST('NOW)' AS TIMESTAMP) FROM RDB$DATABASE; -- succeeds, returns the current timestamp
SELECT CAST('TODAY!' AS DATE) FROM RDB$DATABASE; -- succeeds, returns the current date
SELECT CAST('YESTERDAY-' AS DATE) FROM RDB$DATABASE; -- succeeds, returns yesterday
Two or more garbage characters are rejected correctly, so only the first one slips through:
SELECT CAST('NOW))' AS TIMESTAMP) FROM RDB$DATABASE; -- conversion error, as expected
The effect was confirmed in master, v5.0-release, B3_0_Release.
Cause
CVT_string_to_datetime() in src/common/cvt.cpp validates the rest of the string after the word has been read:
while (++p < end)
{
if (*p != ' ' && *p != '\t' && *p != '\0')
CVT_conversion_error(desc, cb->err);
}
At this point p already points to the first character that was not consumed as a part of the word, so the pre-increment in the condition skips it and it is never checked.
Fix
while (p < end)
{
if (*p != ' ' && *p != '\t' && *p != '\0')
CVT_conversion_error(desc, cb->err);
++p;
}
Trailing blanks, tabs and NULs stay allowed, so CHAR padding keeps working.
Tested on master, B3_0_Release
A single character following
NOW,TODAY,TOMORROWorYESTERDAYis silently ignored instead of raising a conversion error:Two or more garbage characters are rejected correctly, so only the first one slips through:
The effect was confirmed in master, v5.0-release, B3_0_Release.
Cause
CVT_string_to_datetime()insrc/common/cvt.cppvalidates the rest of the string after the word has been read:At this point
palready points to the first character that was not consumed as a part of the word, so the pre-increment in the condition skips it and it is never checked.Fix
Trailing blanks, tabs and NULs stay allowed, so
CHARpadding keeps working.Tested on master, B3_0_Release