From: Heikki Linnakangas Date: Tue, 2 Oct 2012 07:43:48 +0000 (+0300) Subject: Fix access past end of string in date parsing. X-Git-Tag: REL9_0_11~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e291cab0829f48215061a67cc07371cca3cf2e1;p=postgresql Fix access past end of string in date parsing. This affects date_in(), and a couple of other funcions that use DecodeDate(). Hitoshi Harada --- diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index a74dce79f5..899aeb7ae7 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -2168,9 +2168,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)) {