Re: pg_verifybackup: TAR format backup verification - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_verifybackup: TAR format backup verification
Date
Msg-id 1636825.1727733956@sss.pgh.pa.us
Whole thread Raw
In response to Re: pg_verifybackup: TAR format backup verification  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: pg_verifybackup: TAR format backup verification
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Sep 30, 2024 at 11:31 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> WFM, modulo the suggestion about changing data types.

> I would prefer not to make the data type change here because it has
> quite a few tentacles.

I see your point for the function's "len" argument, but perhaps it's
worth doing

-       int            remaining;
+       size_t         remaining;

        remaining = sizeof(ControlFileData) - mystreamer->control_file_bytes;
        memcpy(((char *) &mystreamer->control_file)
               + mystreamer->control_file_bytes,
-              data, Min(len, remaining));
+              data, Min((size_t) len, remaining));

This is enough to ensure the Min() remains safe.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: ACL_MAINTAIN, Lack of comment content
Next
From: Tom Lane
Date:
Subject: Re: pg_upgrade check for invalid databases