Skip to content

Commit 95219c0

Browse files
committed
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
1 parent 1906b1e commit 95219c0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/postmaster/launch_backend.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@ save_backend_variables(BackendParameters *param, ClientSocket *client_sock,
764764
strlcpy(param->pkglib_path, pkglib_path, MAXPGPATH);
765765

766766
param->startup_data_len = startup_data_len;
767-
memcpy(param->startup_data, startup_data, startup_data_len);
767+
if (startup_data_len > 0)
768+
memcpy(param->startup_data, startup_data, startup_data_len);
768769

769770
return true;
770771
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy