mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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
This commit is contained in:
@ -871,7 +871,7 @@ _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Actio
|
|||||||
/* no parallel dump in the custom archive */
|
/* no parallel dump in the custom archive */
|
||||||
Assert(act == ACT_RESTORE);
|
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(nBytes == strlen(str));
|
||||||
Assert(dumpId == te->dumpId);
|
Assert(dumpId == te->dumpId);
|
||||||
|
@ -859,14 +859,14 @@ _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Actio
|
|||||||
|
|
||||||
if (act == ACT_DUMP)
|
if (act == ACT_DUMP)
|
||||||
{
|
{
|
||||||
sscanf(str, "%u%n", &dumpId, &nBytes);
|
sscanf(str, "%d%n", &dumpId, &nBytes);
|
||||||
|
|
||||||
Assert(dumpId == te->dumpId);
|
Assert(dumpId == te->dumpId);
|
||||||
Assert(nBytes == strlen(str));
|
Assert(nBytes == strlen(str));
|
||||||
}
|
}
|
||||||
else if (act == ACT_RESTORE)
|
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(dumpId == te->dumpId);
|
||||||
Assert(nBytes == strlen(str));
|
Assert(nBytes == strlen(str));
|
||||||
|
Reference in New Issue
Block a user