postgres.git / summary / log / commit / refs

commit    61540e6d71764cd595bef7add8d7c5a329547448
Author:   Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date:     Tue Oct 02 07:43:48 2012 +0000

    Fix access past end of string in date parsing.
    
    This affects date_in(), and a couple of other funcions that use DecodeDate().
    
    Hitoshi Harada


src/backend/utils/adt/datetime.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 184c8f441b0..c91a8021758 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -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)) { [parent: 3dbd687488c3]