Fix access past end of string in date parsing.
authorHeikki Linnakangas <[email protected]>
Tue, 2 Oct 2012 07:43:48 +0000 (10:43 +0300)
committerHeikki Linnakangas <[email protected]>
Tue, 2 Oct 2012 07:48:40 +0000 (10:48 +0300)
This affects date_in(), and a couple of other funcions that use DecodeDate().

Hitoshi Harada

src/backend/utils/adt/datetime.c

index 184c8f441b016e88abff98b5840fdd0a5d533f53..c91a802175808e5e154e4ec603cd2fd8a1ab2342 100644 (file)
@@ -2061,9 +2061,12 @@ DecodeDate(char *str, int fmask, int *tmask, bool *is2digits,
    while (*str != '\0' && nf < MAXDATEFIELDS)
    {
        /* skip field separators */
-       while (!isalnum((unsigned char) *str))
+       while (*str != '\0' && !isalnum((unsigned char) *str))
            str++;
 
+       if (*str == '\0')
+           return DTERR_BAD_FORMAT;        /* end of string after separator */
+
        field[nf] = str;
        if (isdigit((unsigned char) *str))
        {