Unbounded %s in sscanf - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Unbounded %s in sscanf
Date
Msg-id B14D3D7B-F98C-4E20-9459-C122C67647FB@yesql.se
Whole thread Raw
Responses Re: Unbounded %s in sscanf  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Unbounded %s in sscanf  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
I happened to spot the below call in src/bin/pg_basebackup/streamutil.c which
has an unbounded %s in the format.

    /* fetch xlog value and unit from the result */
    if (sscanf(PQgetvalue(res, 0, 0), "%d%s", &xlog_val, xlog_unit) != 2)

There is no risk of overflow as the unit is defined to be at most 2 characters,
but that's not explained (like how a similar %s is handled in pg_dump).  The
attached adds a small explanation in the comment to save readers time from
following the bouncing ball to make sure.

--
Daniel Gustafsson        https://vmware.com/


Attachment

pgsql-hackers by date:

Previous
From: Boris Kolpackov
Date:
Subject: Re: Pipeline mode and PQpipelineSync()
Next
From: Andrew Dunstan
Date:
Subject: Re: pgindent run