Protect against small overread in SASLprep validation (This is a cherry-pick of 390b3cbbb, which I hadn't realized wasn't backpatched. It was originally reported to security@ and determined not to be a vulnerability; thanks to Stanislav Osipov for noticing the omission in the back branches.)
In case of torn UTF8 in the input data we might end up going past the end of the string since we don't account for length. While validation won't be performed on a sequence with a NULL byte it's better to avoid going past the end to beging with. Fix by taking the length into consideration. Reported-by: Stanislav Osipov <[email protected]> Reviewed-by: Daniel Gustafsson <[email protected]> Discussion: https://postgr.es/m/CAOYmi+mTnmM172g=_+yvc47hzzeasypy2c4uby3hk9p-axn...@mail.gmail.com Backpatch-through: 14 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/46aaec4c0e6d90e9f074982feb43efd4b3c42a78 Modified Files -------------- src/common/saslprep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
