Use pg_parse_lsn() for IDENTIFY_SYSTEM responses in libpqwalreceiver

libpqwalreceiver parses the WAL flush location returned by
IDENTIFY_SYSTEM using sscanf("%X/%X") into uint32 values. This
accepts overlong components and trailing characters, potentially
producing a different LSN from the one supplied by the upstream server.

Use pg_parse_lsn() instead, requiring one to eight hexadecimal digits
per component and no trailing characters, as for pg_lsn input. Reject
malformed locations with the existing protocol violation error.

Suggested-by: Ayush Tiwari <[email protected]>
Author: Hayato Kuroda <[email protected]>
Reviewed-by: Jan Nidzwetzki <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: 
https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ba6d9ee259cdb2a6c862a4741b16194106e00a9a

Modified Files
--------------
src/backend/replication/libpqwalreceiver/libpqwalreceiver.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

Reply via email to