aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2016-02-18 20:12:38 -0500
committerPeter Eisentraut <peter_e@gmx.net>2016-02-18 20:12:38 -0500
commita914a0414232e30943f7b2ffd997d74bd018a7b1 (patch)
tree3f431ce19d74fb22dc56c99e7e2f85ae1533743b /src
parent19a541143a09c067ec8cac77ec6a64eb5b1b662b (diff)
downloadpostgresql-a914a0414232e30943f7b2ffd997d74bd018a7b1.tar.gz
postgresql-a914a0414232e30943f7b2ffd997d74bd018a7b1.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c2
-rw-r--r--src/bin/pg_dump/pg_backup_directory.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index be6dbca0566..66329dc90c2 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -871,7 +871,7 @@ _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Actio
/* no parallel dump in the custom archive */
Assert(act == ACT_RESTORE);
- sscanf(str, "%u %u %u%n", &dumpId, &status, &n_errors, &nBytes);
+ sscanf(str, "%d %d %d%n", &dumpId, &status, &n_errors, &nBytes);
Assert(nBytes == strlen(str));
Assert(dumpId == te->dumpId);
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
index 727a7fe06fb..1d7b0cc66ad 100644
--- a/src/bin/pg_dump/pg_backup_directory.c
+++ b/src/bin/pg_dump/pg_backup_directory.c
@@ -859,14 +859,14 @@ _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Actio
if (act == ACT_DUMP)
{
- sscanf(str, "%u%n", &dumpId, &nBytes);
+ sscanf(str, "%d%n", &dumpId, &nBytes);
Assert(dumpId == te->dumpId);
Assert(nBytes == strlen(str));
}
else if (act == ACT_RESTORE)
{
- sscanf(str, "%u %u %u%n", &dumpId, &status, &n_errors, &nBytes);
+ sscanf(str, "%d %d %d%n", &dumpId, &status, &n_errors, &nBytes);
Assert(dumpId == te->dumpId);
Assert(nBytes == strlen(str));