From 0899556e92958712cc31953497b82657cc706f94 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 2 Oct 2012 10:43:48 +0300 Subject: [PATCH] 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 d827d7d146..12211c8273 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -2176,9 +2176,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)) { -- 2.40.0