summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/quote.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2016-12-16 12:50:20 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2016-12-16 12:53:16 +0200
commit779325478e7e867c636c3e1ad1e5df734e7549e5 (patch)
tree6717e9604a21c879100533364984db52d17b1c0d /src/backend/utils/adt/quote.c
parentb95f4bf07468165b09c29816def5292200d393cf (diff)
Fix off-by-one in memory allocation for quote_literal_cstr().
The calculation didn't take into account the NULL terminator. That lead to overwriting the palloc'd buffer by one byte, if the input consists entirely of backslashes. For example "format('%L', E'\\')". Fixes bug #14468. Backpatch to all supported versions. Report: https://www.postgresql.org/message-id/20161216105001.13334.42819%40wrigleys.postgresql.org
Diffstat (limited to 'src/backend/utils/adt/quote.c')
-rw-r--r--src/backend/utils/adt/quote.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c
index d1336b4df1b..e43179059af 100644
--- a/src/backend/utils/adt/quote.c
+++ b/src/backend/utils/adt/quote.c
@@ -107,7 +107,7 @@ quote_literal_cstr(const char *rawstr)
len = strlen(rawstr);
/* We make a worst-case result area; wasting a little space is OK */
- result = palloc(len * 2 + 3);
+ result = palloc(len * 2 + 3 + 1);
newlen = quote_literal_internal(result, rawstr, len);
result[newlen] = '\0';