[6.0] 3de983328 vtest: put cwd on the stack

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Oct 25 07:01:08 UTC 2021


commit 3de9833284f49b23b8b19f3f7c74bebaf07f474d
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Oct 15 12:01:35 2020 +0200

    vtest: put cwd on the stack
    
    0051cbe3b9cc24586e0ad99cff72041c6df944b8 did not work on
    solaris-descendents, the man page clearly states that the size argument
    also determines the buffer to be malloc()ed for a NULL buffer argument.

diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index 4b4f8fa11..516ff99c4 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -540,6 +540,7 @@ main(int argc, char * const *argv)
 	int ntest = 1;			/* Run tests this many times */
 	uintmax_t bufsiz;
 	const char *p;
+	char buf[PATH_MAX];
 
 	argv0 = strrchr(argv[0], '/');
 	if (argv0 == NULL)
@@ -552,7 +553,7 @@ main(int argc, char * const *argv)
 	else
 		tmppath = strdup("/tmp");
 
-	cwd = getcwd(NULL, 0);
+	cwd = getcwd(buf, sizeof buf);
 	extmacro_def("pwd", "%s", cwd);
 
 	vmod_path = NULL;


More information about the varnish-commit mailing list