pgsql: Avoid 0-length memcpy to NULL with EXEC_BACKEND

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid 0-length memcpy to NULL with EXEC_BACKEND
Date: 2024-07-03 13:22:47
Message-ID: E1sOzwc-0009yv-CT@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid 0-length memcpy to NULL with EXEC_BACKEND

memcpy(NULL, src, 0) is forbidden by POSIX, even though every
production version of libc allows it. Let's be tidy.

Per report from Thomas Munro, running UBSan with EXEC_BACKEND.
Backpatch to v17, where this code was added.

Discussion: https://www.postgresql.org/message-id/CA%2BhUKG%2Be-dV7YWBzfBZXsgovgRuX5VmvmOT%2Bv0aXiZJ-EKbXcw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f3412a61f3f92d795ce0c8bb715831ec02124bfb

Modified Files
--------------
src/backend/postmaster/launch_backend.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2024-07-03 15:59:20 pgsql: Remove is_index parameter from binary_upgrade_set_pg_class_oids(
Previous Message Amit Kapila 2024-07-03 09:50:23 pgsql: Fix the testcase introduced in commit 81d20fbf7a.