Skip to content

Commit 3e291ca

Browse files
committed
Fix access past end of string in date parsing.
This affects date_in(), and a couple of other funcions that use DecodeDate(). Hitoshi Harada
1 parent 54152d0 commit 3e291ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2168,9 +2168,12 @@ DecodeDate(char *str, int fmask, int *tmask, bool *is2digits,
21682168
while (*str != '\0' && nf < MAXDATEFIELDS)
21692169
{
21702170
/* skip field separators */
2171-
while (!isalnum((unsigned char) *str))
2171+
while (*str != '\0' && !isalnum((unsigned char) *str))
21722172
str++;
21732173

2174+
if (*str == '\0')
2175+
return DTERR_BAD_FORMAT; /* end of string after separator */
2176+
21742177
field[nf] = str;
21752178
if (isdigit((unsigned char) *str))
21762179
{

0 commit comments

Comments
 (0)