Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a914a04

Browse filesBrowse 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
Copy full SHA for a914a04

File tree

Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed

‎src/bin/pg_dump/pg_backup_custom.c

Copy file name to clipboardExpand all lines: src/bin/pg_dump/pg_backup_custom.c
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/bin/pg_dump/pg_backup_directory.c
+2-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.