From: Tom Lane Date: Tue, 3 Feb 2004 17:56:04 +0000 (+0000) Subject: Ensure that memcmp() does not run off the end of memory, per Kurt Roeckx. X-Git-Tag: REL7_4_2~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2194ed88de490e303811debd454199ba0fd69558;p=postgresql Ensure that memcmp() does not run off the end of memory, per Kurt Roeckx. (Same patch committed to HEAD but I fat-fingered the commit message...) --- diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 66976b9d83..babafa0b98 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.49 2003/08/08 21:42:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.49.4.1 2004/02/03 17:56:04 tgl Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -118,7 +118,8 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len, */ for (i = 0; i < num_res; i++) { - if (memcmp(re_array[i].cre_pat, text_re, text_re_len) == 0 && + if (VARSIZE(re_array[i].cre_pat) == text_re_len && + memcmp(re_array[i].cre_pat, text_re, text_re_len) == 0 && re_array[i].cre_flags == cflags) { /*