Summary: | [patch] Fix build on Hurd without PATH_MAX | ||
---|---|---|---|
Product: | Spice | Reporter: | Petter Reinholdtsen <pere> |
Component: | server | Assignee: | Spice Bug List <spice-bugs> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | medium | CC: | pochu27 |
Version: | unspecified | ||
Hardware: | x86 (IA32) | ||
OS: | other | ||
Whiteboard: | |||
i915 platform: | i915 features: |
Description
Petter Reinholdtsen
2014-02-01 11:02:24 UTC
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.