Skip to content

Commit f3412a6

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 a06e8f8 commit f3412a6

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
@@ -762,7 +762,8 @@ save_backend_variables(BackendParameters *param, ClientSocket *client_sock,
762762
strlcpy(param->pkglib_path, pkglib_path, MAXPGPATH);
763763

764764
param->startup_data_len = startup_data_len;
765-
memcpy(param->startup_data, startup_data, startup_data_len);
765+
if (startup_data_len > 0)
766+
memcpy(param->startup_data, startup_data, startup_data_len);
766767

767768
return true;
768769
}

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