From: Tom Lane Date: Sat, 21 Feb 2015 17:59:25 +0000 (-0500) Subject: Fix misparsing of empty value in conninfo_uri_parse_params(). X-Git-Tag: REL9_5_ALPHA1~739 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b26e2081423cf1c70f83a11787351017c97cfd7c;p=postgresql Fix misparsing of empty value in conninfo_uri_parse_params(). After finding an "=" character, the pointer was advanced twice when it should only advance once. This is harmless as long as the value after "=" has at least one character; but if it doesn't, we'd miss the terminator character and include too much in the value. In principle this could lead to reading off the end of memory. It does not seem worth treating as a security issue though, because it would happen on client side, and besides client logic that's taking conninfo strings from untrusted sources has much worse security problems than this. Report and patch received off-list from Thomas Fanghaenel. Back-patch to 9.2 where the faulty code was introduced. --- diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 25961b1f10..17f34cf8b5 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -4966,9 +4966,8 @@ conninfo_uri_parse_params(char *params, ++p; break; } - - /* Advance, NUL is checked in the 'if' above */ - ++p; + else + ++p; /* Advance over all other bytes. */ } keyword = conninfo_uri_decode(keyword, errorMessage);