pg_basebackup_sscanf.diff
application/octet-stream
Filename: pg_basebackup_sscanf.diff
Type: application/octet-stream
Part: 0
Message:
Unbounded %s in sscanf
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/bin/pg_basebackup/streamutil.c | 4 | 1 |
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index 99daf0e972..6602858491 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -309,7 +309,10 @@ RetrieveWalSegSize(PGconn *conn)
return false;
}
- /* fetch xlog value and unit from the result */
+ /*
+ * Fetch xlog value and unit from the result. Can't overflow since the unit
+ * is at most two characters.
+ */
if (sscanf(PQgetvalue(res, 0, 0), "%d%s", &xlog_val, xlog_unit) != 2)
{
pg_log_error("WAL segment size could not be parsed");