Skip to content

Commit a914a04

Browse files
committed
pg_dump: Fix inconsistent sscanf() conversions
It was using %u to read a string that was earlier produced by snprintf with %d into a signed integer variable. This seems to work in practice but is incorrect. found by cppcheck
1 parent 19a5411 commit a914a04

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/bin/pg_dump/pg_backup_custom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Actio
871871
/* no parallel dump in the custom archive */
872872
Assert(act == ACT_RESTORE);
873873

874-
sscanf(str, "%u %u %u%n", &dumpId, &status, &n_errors, &nBytes);
874+
sscanf(str, "%d %d %d%n", &dumpId, &status, &n_errors, &nBytes);
875875

876876
Assert(nBytes == strlen(str));
877877
Assert(dumpId == te->dumpId);

src/bin/pg_dump/pg_backup_directory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,14 +859,14 @@ _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Actio
859859

860860
if (act == ACT_DUMP)
861861
{
862-
sscanf(str, "%u%n", &dumpId, &nBytes);
862+
sscanf(str, "%d%n", &dumpId, &nBytes);
863863

864864
Assert(dumpId == te->dumpId);
865865
Assert(nBytes == strlen(str));
866866
}
867867
else if (act == ACT_RESTORE)
868868
{
869-
sscanf(str, "%u %u %u%n", &dumpId, &status, &n_errors, &nBytes);
869+
sscanf(str, "%d %d %d%n", &dumpId, &status, &n_errors, &nBytes);
870870

871871
Assert(dumpId == te->dumpId);
872872
Assert(nBytes == strlen(str));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy