mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
File size in a backup manifest should use uint64, not size_t.
size_t is the size of an object in memory, not the size of a file on disk. Thanks to Tom Lane for noting the error. Discussion: http://postgr.es/m/1865585.1727803933@sss.pgh.pa.us
This commit is contained in:
parent
7b2822ecf9
commit
d94cf5ca7f
@ -60,7 +60,7 @@ static void combinebackup_version_cb(JsonManifestParseContext *context,
|
|||||||
static void combinebackup_system_identifier_cb(JsonManifestParseContext *context,
|
static void combinebackup_system_identifier_cb(JsonManifestParseContext *context,
|
||||||
uint64 manifest_system_identifier);
|
uint64 manifest_system_identifier);
|
||||||
static void combinebackup_per_file_cb(JsonManifestParseContext *context,
|
static void combinebackup_per_file_cb(JsonManifestParseContext *context,
|
||||||
const char *pathname, size_t size,
|
const char *pathname, uint64 size,
|
||||||
pg_checksum_type checksum_type,
|
pg_checksum_type checksum_type,
|
||||||
int checksum_length,
|
int checksum_length,
|
||||||
uint8 *checksum_payload);
|
uint8 *checksum_payload);
|
||||||
@ -267,7 +267,7 @@ combinebackup_system_identifier_cb(JsonManifestParseContext *context,
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
combinebackup_per_file_cb(JsonManifestParseContext *context,
|
combinebackup_per_file_cb(JsonManifestParseContext *context,
|
||||||
const char *pathname, size_t size,
|
const char *pathname, uint64 size,
|
||||||
pg_checksum_type checksum_type,
|
pg_checksum_type checksum_type,
|
||||||
int checksum_length, uint8 *checksum_payload)
|
int checksum_length, uint8 *checksum_payload)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ typedef struct manifest_file
|
|||||||
{
|
{
|
||||||
uint32 status; /* hash status */
|
uint32 status; /* hash status */
|
||||||
const char *pathname;
|
const char *pathname;
|
||||||
size_t size;
|
uint64 size;
|
||||||
pg_checksum_type checksum_type;
|
pg_checksum_type checksum_type;
|
||||||
int checksum_length;
|
int checksum_length;
|
||||||
uint8 *checksum_payload;
|
uint8 *checksum_payload;
|
||||||
|
@ -74,7 +74,7 @@ create_manifest_writer(char *directory, uint64 system_identifier)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
add_file_to_manifest(manifest_writer *mwriter, const char *manifest_path,
|
add_file_to_manifest(manifest_writer *mwriter, const char *manifest_path,
|
||||||
size_t size, time_t mtime,
|
uint64 size, time_t mtime,
|
||||||
pg_checksum_type checksum_type,
|
pg_checksum_type checksum_type,
|
||||||
int checksum_length,
|
int checksum_length,
|
||||||
uint8 *checksum_payload)
|
uint8 *checksum_payload)
|
||||||
@ -104,7 +104,8 @@ add_file_to_manifest(manifest_writer *mwriter, const char *manifest_path,
|
|||||||
appendStringInfoString(&mwriter->buf, "\", ");
|
appendStringInfoString(&mwriter->buf, "\", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendStringInfo(&mwriter->buf, "\"Size\": %zu, ", size);
|
appendStringInfo(&mwriter->buf, "\"Size\": %llu, ",
|
||||||
|
(unsigned long long) size);
|
||||||
|
|
||||||
appendStringInfoString(&mwriter->buf, "\"Last-Modified\": \"");
|
appendStringInfoString(&mwriter->buf, "\"Last-Modified\": \"");
|
||||||
enlargeStringInfo(&mwriter->buf, 128);
|
enlargeStringInfo(&mwriter->buf, 128);
|
||||||
|
@ -23,7 +23,7 @@ extern manifest_writer *create_manifest_writer(char *directory,
|
|||||||
uint64 system_identifier);
|
uint64 system_identifier);
|
||||||
extern void add_file_to_manifest(manifest_writer *mwriter,
|
extern void add_file_to_manifest(manifest_writer *mwriter,
|
||||||
const char *manifest_path,
|
const char *manifest_path,
|
||||||
size_t size, time_t mtime,
|
uint64 size, time_t mtime,
|
||||||
pg_checksum_type checksum_type,
|
pg_checksum_type checksum_type,
|
||||||
int checksum_length,
|
int checksum_length,
|
||||||
uint8 *checksum_payload);
|
uint8 *checksum_payload);
|
||||||
|
@ -207,9 +207,11 @@ member_verify_header(astreamer *streamer, astreamer_member *member)
|
|||||||
if (m->size != member->size)
|
if (m->size != member->size)
|
||||||
{
|
{
|
||||||
report_backup_error(mystreamer->context,
|
report_backup_error(mystreamer->context,
|
||||||
"\"%s\" has size %lld in \"%s\" but size %zu in the manifest",
|
"\"%s\" has size %llu in \"%s\" but size %llu in the manifest",
|
||||||
member->pathname, (long long int) member->size,
|
member->pathname,
|
||||||
mystreamer->archive_name, m->size);
|
(unsigned long long) member->size,
|
||||||
|
mystreamer->archive_name,
|
||||||
|
(unsigned long long) m->size);
|
||||||
m->bad = true;
|
m->bad = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -294,9 +296,10 @@ member_verify_checksum(astreamer *streamer)
|
|||||||
if (mystreamer->checksum_bytes != m->size)
|
if (mystreamer->checksum_bytes != m->size)
|
||||||
{
|
{
|
||||||
report_backup_error(mystreamer->context,
|
report_backup_error(mystreamer->context,
|
||||||
"file \"%s\" in \"%s\" should contain %zu bytes, but read %zu bytes",
|
"file \"%s\" in \"%s\" should contain %llu bytes, but read %llu bytes",
|
||||||
m->pathname, mystreamer->archive_name,
|
m->pathname, mystreamer->archive_name,
|
||||||
m->size, mystreamer->checksum_bytes);
|
(unsigned long long) m->size,
|
||||||
|
(unsigned long long) mystreamer->checksum_bytes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ static void verifybackup_version_cb(JsonManifestParseContext *context,
|
|||||||
static void verifybackup_system_identifier(JsonManifestParseContext *context,
|
static void verifybackup_system_identifier(JsonManifestParseContext *context,
|
||||||
uint64 manifest_system_identifier);
|
uint64 manifest_system_identifier);
|
||||||
static void verifybackup_per_file_cb(JsonManifestParseContext *context,
|
static void verifybackup_per_file_cb(JsonManifestParseContext *context,
|
||||||
const char *pathname, size_t size,
|
const char *pathname, uint64 size,
|
||||||
pg_checksum_type checksum_type,
|
pg_checksum_type checksum_type,
|
||||||
int checksum_length,
|
int checksum_length,
|
||||||
uint8 *checksum_payload);
|
uint8 *checksum_payload);
|
||||||
@ -547,7 +547,7 @@ verifybackup_system_identifier(JsonManifestParseContext *context,
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
verifybackup_per_file_cb(JsonManifestParseContext *context,
|
verifybackup_per_file_cb(JsonManifestParseContext *context,
|
||||||
const char *pathname, size_t size,
|
const char *pathname, uint64 size,
|
||||||
pg_checksum_type checksum_type,
|
pg_checksum_type checksum_type,
|
||||||
int checksum_length, uint8 *checksum_payload)
|
int checksum_length, uint8 *checksum_payload)
|
||||||
{
|
{
|
||||||
@ -719,8 +719,9 @@ verify_plain_backup_file(verifier_context *context, char *relpath,
|
|||||||
if (m->size != sb.st_size)
|
if (m->size != sb.st_size)
|
||||||
{
|
{
|
||||||
report_backup_error(context,
|
report_backup_error(context,
|
||||||
"\"%s\" has size %lld on disk but size %zu in the manifest",
|
"\"%s\" has size %llu on disk but size %llu in the manifest",
|
||||||
relpath, (long long int) sb.st_size, m->size);
|
relpath, (unsigned long long) sb.st_size,
|
||||||
|
(unsigned long long) m->size);
|
||||||
m->bad = true;
|
m->bad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,7 +1102,7 @@ verify_file_checksum(verifier_context *context, manifest_file *m,
|
|||||||
const char *relpath = m->pathname;
|
const char *relpath = m->pathname;
|
||||||
int fd;
|
int fd;
|
||||||
int rc;
|
int rc;
|
||||||
size_t bytes_read = 0;
|
uint64 bytes_read = 0;
|
||||||
uint8 checksumbuf[PG_CHECKSUM_MAX_LENGTH];
|
uint8 checksumbuf[PG_CHECKSUM_MAX_LENGTH];
|
||||||
int checksumlen;
|
int checksumlen;
|
||||||
|
|
||||||
@ -1164,8 +1165,9 @@ verify_file_checksum(verifier_context *context, manifest_file *m,
|
|||||||
if (bytes_read != m->size)
|
if (bytes_read != m->size)
|
||||||
{
|
{
|
||||||
report_backup_error(context,
|
report_backup_error(context,
|
||||||
"file \"%s\" should contain %zu bytes, but read %zu bytes",
|
"file \"%s\" should contain %llu bytes, but read %llu bytes",
|
||||||
relpath, m->size, bytes_read);
|
relpath, (unsigned long long) m->size,
|
||||||
|
(unsigned long long) bytes_read);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ typedef struct manifest_file
|
|||||||
{
|
{
|
||||||
uint32 status; /* hash status */
|
uint32 status; /* hash status */
|
||||||
const char *pathname;
|
const char *pathname;
|
||||||
size_t size;
|
uint64 size;
|
||||||
pg_checksum_type checksum_type;
|
pg_checksum_type checksum_type;
|
||||||
int checksum_length;
|
int checksum_length;
|
||||||
uint8 *checksum_payload;
|
uint8 *checksum_payload;
|
||||||
|
@ -650,7 +650,7 @@ static void
|
|||||||
json_manifest_finalize_file(JsonManifestParseState *parse)
|
json_manifest_finalize_file(JsonManifestParseState *parse)
|
||||||
{
|
{
|
||||||
JsonManifestParseContext *context = parse->context;
|
JsonManifestParseContext *context = parse->context;
|
||||||
size_t size;
|
uint64 size;
|
||||||
char *ep;
|
char *ep;
|
||||||
int checksum_string_length;
|
int checksum_string_length;
|
||||||
pg_checksum_type checksum_type;
|
pg_checksum_type checksum_type;
|
||||||
@ -688,7 +688,7 @@ json_manifest_finalize_file(JsonManifestParseState *parse)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse size. */
|
/* Parse size. */
|
||||||
size = strtoul(parse->size, &ep, 10);
|
size = strtou64(parse->size, &ep, 10);
|
||||||
if (*ep)
|
if (*ep)
|
||||||
json_manifest_parse_failure(parse->context,
|
json_manifest_parse_failure(parse->context,
|
||||||
"file size is not an integer");
|
"file size is not an integer");
|
||||||
|
@ -28,7 +28,7 @@ typedef void (*json_manifest_system_identifier_callback) (JsonManifestParseConte
|
|||||||
uint64 manifest_system_identifier);
|
uint64 manifest_system_identifier);
|
||||||
typedef void (*json_manifest_per_file_callback) (JsonManifestParseContext *,
|
typedef void (*json_manifest_per_file_callback) (JsonManifestParseContext *,
|
||||||
const char *pathname,
|
const char *pathname,
|
||||||
size_t size, pg_checksum_type checksum_type,
|
uint64 size, pg_checksum_type checksum_type,
|
||||||
int checksum_length, uint8 *checksum_payload);
|
int checksum_length, uint8 *checksum_payload);
|
||||||
typedef void (*json_manifest_per_wal_range_callback) (JsonManifestParseContext *,
|
typedef void (*json_manifest_per_wal_range_callback) (JsonManifestParseContext *,
|
||||||
TimeLineID tli,
|
TimeLineID tli,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user