]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't cast off_t to 32-bit type for output, bug fix
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 1 Jul 2026 07:40:36 +0000 (09:40 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 1 Jul 2026 07:49:39 +0000 (09:49 +0200)
off_t is most likely a 64-bit integer, so casting it to a 32-bit type
for output could lose data.  There are more issues like this in the
tree, but this is an instance where this could actually happen in
practice, since base backups are routinely larger than 4 GB.  So this
is separated out as a bug fix.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://www.postgresql.org/message-id/flat/20ce62fa-47fc-457b-b504-12f3c1651726%40eisentraut.org

src/backend/backup/basebackup_server.c

index 0258d7a03b3ee8542bf8bce73b66468ad4b690d5..4efc6bd049d6fd46bd55ee67d3db09955ed2a519 100644 (file)
@@ -176,9 +176,9 @@ bbsink_server_archive_contents(bbsink *sink, size_t len)
                /* short write: complain appropriately */
                ereport(ERROR,
                                (errcode(ERRCODE_DISK_FULL),
-                                errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %u",
+                                errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %lld",
                                                FilePathName(mysink->file),
-                                               nbytes, (int) len, (unsigned) mysink->filepos),
+                                               nbytes, (int) len, (long long) mysink->filepos),
                                 errhint("Check free disk space.")));
        }
 
@@ -269,9 +269,9 @@ bbsink_server_manifest_contents(bbsink *sink, size_t len)
                /* short write: complain appropriately */
                ereport(ERROR,
                                (errcode(ERRCODE_DISK_FULL),
-                                errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %u",
+                                errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %lld",
                                                FilePathName(mysink->file),
-                                               nbytes, (int) len, (unsigned) mysink->filepos),
+                                               nbytes, (int) len, (long long) mysink->filepos),
                                 errhint("Check free disk space.")));
        }