proctitle.diff

text/x-diff

Filename: proctitle.diff
Type: text/x-diff
Part: 0
Message: Re: Regression tests fail with musl libc because libpq.so can't be loaded

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/utils/misc/ps_status.c 26 1
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index 5d829e6e483..154862f9fb0 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -151,7 +151,32 @@ save_ps_display_args(int argc, char **argv)
 		for (i = 0; environ[i] != NULL; i++)
 		{
 			if (end_of_area + 1 == environ[i])
-				end_of_area = environ[i] + strlen(environ[i]);
+			{
+
+				/* Do this for Linux libc libraries that might be unsafe. */
+#if ! defined(__linux__) || (! defined(__GLIBC__) && defined(__UCLIBC__ ))
+				/*
+				 * If we see variables that the musl runtime linker is known
+				 * to stash pointers to, give up so we don't break later calls
+				 * to dlopen().
+				 */
+				if (strstr(environ[i], "LD_LIBRARY_PATH=") == environ[i] ||
+					strstr(environ[i], "LD_PRELOAD=") == environ[i])
+				{
+					/*
+					 * We can overwrite the name, but stop at the equals sign.
+					 * Future loops will not find contiguous space, but we
+					 * don't break early because we want to count the total
+					 * number.
+					 */
+					end_of_area = strchr(environ[i], '=');
+				}
+				else
+#endif
+				{
+					end_of_area = environ[i] + strlen(environ[i]);
+				}
+			}
 		}
 
 		ps_buffer = argv[0];