Skip to content

Commit 6c00b2b

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 d617b28 commit 6c00b2b

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
@@ -2169,9 +2169,12 @@ DecodeDate(char *str, int fmask, int *tmask, bool *is2digits,
21692169
while (*str != '\0' && nf < MAXDATEFIELDS)
21702170
{
21712171
/* skip field separators */
2172-
while (!isalnum((unsigned char) *str))
2172+
while (*str != '\0' && !isalnum((unsigned char) *str))
21732173
str++;
21742174

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

0 commit comments

Comments
 (0)