diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-07-07 21:12:53 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-07-07 21:12:53 +0000 |
commit | 65da0d66b4e89951078ebc43a5343780e4e700d6 (patch) | |
tree | 8bc075c2b755432ac3c51516a0fdbc7dfd0e3c12 /src/backend/utils/adt/regexp.c | |
parent | de85dd1d51ab7325984ef36302831ca21e3ae53e (diff) | |
download | postgresql-65da0d66b4e89951078ebc43a5343780e4e700d6.tar.gz postgresql-65da0d66b4e89951078ebc43a5343780e4e700d6.zip |
Fix misuse of StrNCpy to copy and add null to non-null-terminated data.
Does not work since it fetches one byte beyond the source data, and when
the phase of the moon is wrong, the source data is smack up against the
end of backend memory and you get SIGSEGV. Don't laugh, this is a fix
for an actual user bug report.
Diffstat (limited to 'src/backend/utils/adt/regexp.c')
-rw-r--r-- | src/backend/utils/adt/regexp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index dcf158c7a28..5e9a91dbf48 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.32 2000/07/06 05:48:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.33 2000/07/07 21:12:50 tgl Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -164,7 +164,8 @@ fixedlen_regexeq(char *s, text *p, int charlen, int cflags) /* be sure sterm is null-terminated */ sterm = (char *) palloc(charlen + 1); - StrNCpy(sterm, s, charlen + 1); + memcpy(sterm, s, charlen); + sterm[charlen] = '\0'; result = RE_compile_and_execute(p, sterm, cflags); |