Fix off-by-one in memory allocation for quote_literal_cstr().

Heikki Linnakangas <heikki.linnakangas@iki.fi>

Commit: 595333ff493a3b17d82133a01cd64128bb6175b7
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: 2016-12-16T10:53:12Z
Releases: 9.5.6
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

Files

PathChange+/−
src/backend/utils/adt/quote.c modified +1 −1