Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)
Date
Msg-id CAEudQAoT7GWNd1v2qgAT4f7chiwvx-GGJXxdHzODXjYkbQYQuw@mail.gmail.com
Whole thread Raw
Responses Re:Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)
Re: Avoid an odd undefined behavior with memcmp (src/bin/pg_rewind/pg_rewind.c)
List pgsql-hackers
Hi.

The function *perform_rewind* has an odd undefined behavior.
The function memcmp/, compares bytes to bytes.

IMO, I think that pg_rewind can have a security issue,
if two files are exactly the same, they are considered different.
Because use of structs with padding values is unspecified.

Fix by explicitly initializing with memset to avoid this.

best regards,
Ranier Vilela
Attachment

pgsql-hackers by date:

Previous
From: Imran Zaheer
Date:
Subject: Re: errors building on windows using meson
Next
From: Dave Page
Date:
Subject: Windows: openssl & gssapi dislike each other