Re: Patch to allow pg_filedump to support reading of pg_filenode.map - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: Patch to allow pg_filedump to support reading of pg_filenode.map
Date
Msg-id 20210429044231.GH27406@telsasoft.com
Whole thread Raw
In response to Patch to allow pg_filedump to support reading of pg_filenode.map  (Richard Yen <richyen3@gmail.com>)
Responses Re: Patch to allow pg_filedump to support reading of pg_filenode.map  (Richard Yen <richyen3@gmail.com>)
List pgsql-hackers
This is separate from the postgresql server repo.
https://git.postgresql.org/gitweb/?p=pg_filedump.git

+#define RELMAPPER_FILEMAGIC   0x592717
+char magic_buffer[8];

...

+  if ( (int) magic_buffer & RELMAPPER_FILEMAGIC ) {

This is doing bitwise arithmetic on a pointer, which seems badly wrong.
I think it breaks normal use of pg_filedump - unless you happen to get a
magic_buffer without those bits set.  The segfault seems to confirm that, as
does gcc:

pg_filedump.c:2041:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 2041 |   if ( (int) magic_buffer & RELMAPPER_FILEMAGIC ) {

I think it probably means to do memcmp, instead ??

-- 
Justin



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: WIP: WAL prefetch (another approach)
Next
From: Peter Eisentraut
Date:
Subject: Re: pg_hba.conf.sample wording improvement