Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix access past end of string in date parsing.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 2 Oct 2012 07:43:48 +0000 (10:43 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 2 Oct 2012 07:47:39 +0000 (10:47 +0300)
This affects date_in(), and a couple of other funcions that use DecodeDate().

Hitoshi Harada

src/backend/utils/adt/datetime.c

index a3be406b684640aea894f251d3d1689ddf675740..e4866ce26c0d3b9d54da91164a66135a39c9bd04 100644 (file)
@@ -2169,9 +2169,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))
        {