The following patch fixes the server build on Hurd, where PATH_MAX is not available. With the fix, all the server part of spice builds on Hurd. I'm also looking at the client part, but it require thread features I do not yet know on Hurd. --- spice-0.12.4.orig/server/tests/test_display_base.c +++ spice-0.12.4/server/tests/test_display_base.c @@ -87,12 +87,13 @@ static void regression_test(void) pid = fork(); if (pid == 0) { - char buf[PATH_MAX]; + char *buf = malloc(strlen(getenv("PATH"))+6); char *argp[] = {NULL}; char *envp[] = {buf, NULL}; snprintf(buf, sizeof(buf), "PATH=%s", getenv("PATH")); execve("regression_test.py", argp, envp); + free(buf); /* In case the exec fail */ } else if (pid > 0) { return; } -- Happy hacking Petter Reinholdtsen
snprintf(buf, sizeof(buf), "PATH=%s", getenv("PATH")); Won't this just write up to sizeof(buf) bytes, that is, up to sizeof(char *), which is normally 4 or 8 bytes? I think you want to change sizeof(buf) with strlen(getenv("PATH"))+6 (ideally caching the result in a new len variable to avoid doing that calculation twice).
You are right. Sorry. I got so excided when I got it building I forgot to update the snprintf() call too. Here is an updated patch. --- spice-0.12.4.orig/server/tests/test_display_base.c +++ spice-0.12.4/server/tests/test_display_base.c @@ -87,12 +87,14 @@ static void regression_test(void) pid = fork(); if (pid == 0) { - char buf[PATH_MAX]; + int buflen = strlen(getenv("PATH"))+6; + char *buf = malloc(buflen); char *argp[] = {NULL}; char *envp[] = {buf, NULL}; - snprintf(buf, sizeof(buf), "PATH=%s", getenv("PATH")); + snprintf(buf, buflen, "PATH=%s", getenv("PATH")); execve("regression_test.py", argp, envp); + free(buf); /* In case the exec fail */ } else if (pid > 0) { return; }
I'd just add a #ifndef PATH_MAX #define PATH_MAX 4096 #endif somewhere after all the #includes at the top of the file.
please provide updated patch if still required
(In reply to Marc-Andre Lureau from comment #4) > please provide updated patch if still required Patch sent to ML: http://lists.freedesktop.org/archives/spice-devel/2015-February/019024.html
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.