Re: Patch: incorrect array offset in backend replication tar header

From: Brian Weaver <cmdrclueless(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch: incorrect array offset in backend replication tar header
Date: 2012-09-25 00:13:30
Message-ID: CAAhXZGtFgGLGODevtLzY_hVQKQ2Bravj7C+HUx7Kbtse=KPdjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Actually I found one other issue while continuing my investigation.
The insertion of the 'ustar' and version '00' has the '00' version at
the wrong offset. The patch is attached.

-- Brian

On Mon, Sep 24, 2012 at 7:51 PM, Brian Weaver <cmdrclueless(at)gmail(dot)com> wrote:
> While researching the way streaming replication works I was examining
> the construction of the tar file header. By comparing documentation on
> the tar header format from various sources I certain the following
> patch should be applied to so the group identifier is put into thee
> header properly.
>
> While I realize that wikipedia isn't always the best source of
> information, the header offsets seem to match the other documentation
> I've found. The format is just easier to read on wikipedia
>
> http://en.wikipedia.org/wiki/Tar_(file_format)#File_header
>
> Here is the trivial patch:
>
> diff --git a/src/backend/replication/basebackup.c
> b/src/backend/replication/basebackup.c
> index 4aaa9e3..524223e 100644
> --- a/src/backend/replication/basebackup.c
> +++ b/src/backend/replication/basebackup.c
> @@ -871,7 +871,7 @@ _tarWriteHeader(const char *filename, const char
> *linktarget,
> sprintf(&h[108], "%07o ", statbuf->st_uid);
>
> /* Group 8 */
> - sprintf(&h[117], "%07o ", statbuf->st_gid);
> + sprintf(&h[116], "%07o ", statbuf->st_gid);
>
> /* File size 12 - 11 digits, 1 space, no NUL */
> if (linktarget != NULL || S_ISDIR(statbuf->st_mode))
>
>
> -- Brian
>
> --
>
> /* insert witty comment here */

--

/* insert witty comment here */

Attachment Content-Type Size
pg-tar.patch application/octet-stream 835 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brian Weaver 2012-09-25 00:20:30 Re: Patch: incorrect array offset in backend replication tar header
Previous Message Andres Freund 2012-09-24 23:58:31 Re: DROP INDEX CONCURRENTLY is not really concurrency safe & leaves around undroppable indexes