Hello, Here is a fixed patch for 0.9.15.
Samuel
--- src/pulsecore/authkey.c.orig 2009-03-31 01:55:38.450000000 +0100 +++ src/pulsecore/authkey.c 2009-03-31 02:12:17.570000000 +0100 @@ -36,6 +36,7 @@ #include <sys/stat.h> #include <pulse/util.h> +#include <pulse/xmalloc.h> #include <pulsecore/core-error.h> #include <pulsecore/core-util.h> #include <pulsecore/log.h> @@ -158,16 +159,27 @@ #else if (strlen(fn) < 3 || !isalpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') { #endif - char homedir[PATH_MAX]; + char *homedir; + size_t allocated = 128; - if (!pa_get_home_dir(homedir, sizeof(homedir))) - return NULL; + while (1) { + homedir = pa_xmalloc(allocated); + if (!pa_get_home_dir(homedir, allocated)) { + pa_xfree(homedir); + return NULL; + } + if (strlen(homedir) < allocated - 1) + break; + pa_xfree(homedir); + allocated *= 2; + } #ifndef OS_IS_WIN32 pa_snprintf(s, l, "%s/%s", homedir, fn); #else pa_snprintf(s, l, "%s\\%s", homedir, fn); #endif + pa_xfree(homedir); return s; } @@ -177,17 +189,35 @@ /* Load a cookie from a file in the home directory. If the specified * path starts with /, use it as absolute path instead. */ int pa_authkey_load_auto(const char *fn, void *data, size_t length) { - char path[PATH_MAX]; + char *path; const char *p; + size_t allocated = 128; + int key; pa_assert(fn); pa_assert(data); pa_assert(length > 0); - if (!(p = normalize_path(fn, path, sizeof(path)))) - return -2; + while (1) { + path = pa_xmalloc(allocated); + + if (!(p = normalize_path(fn, path, allocated))) { + pa_xfree(path); + return -2; + } + + if (p != path || strlen(path) < allocated - 1) + break; + + pa_xfree(path); + allocated *= 2; + } + + key = pa_authkey_load(p, data, length); - return pa_authkey_load(p, data, length); + pa_xfree(path); + + return key; } /* Store the specified cookie in the speicified cookie file */ @@ -195,15 +225,28 @@ int fd = -1; int unlock = 0, ret = -1; ssize_t r; - char path[PATH_MAX]; + char *path; const char *p; + size_t allocated = 128; pa_assert(fn); pa_assert(data); pa_assert(length > 0); - if (!(p = normalize_path(fn, path, sizeof(path)))) - return -2; + while (1) { + path = pa_xmalloc(allocated); + + if (!(p = normalize_path(fn, path, allocated))) { + pa_xfree(path); + return -2; + } + + if (p != path || strlen(path) < allocated - 1) + break; + + pa_xfree(path); + allocated *= 2; + } if ((fd = open(p, O_RDWR|O_CREAT|O_NOCTTY, S_IRUSR|S_IWUSR)) < 0) { pa_log_warn("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno)); @@ -232,5 +275,7 @@ } } + pa_xfree(path); + return ret; } --- src/pulsecore/core-util.c.orig 2009-03-31 02:12:50.960000000 +0100 +++ src/pulsecore/core-util.c 2009-03-31 02:22:25.750000000 +0100 @@ -1265,26 +1265,42 @@ } static char *get_pulse_home(void) { - char h[PATH_MAX]; + char *h; struct stat st; + size_t allocated = 128; + char *ret = NULL; - if (!pa_get_home_dir(h, sizeof(h))) { - pa_log_error("Failed to get home directory."); - return NULL; + while (1) { + h = pa_xmalloc(allocated); + + if (!pa_get_home_dir(h, allocated)) { + pa_log_error("Failed to get home directory."); + goto out; + } + + if (strlen(h) < allocated - 1) + break; + + pa_xfree(h); + allocated *= 2; } if (stat(h, &st) < 0) { pa_log_error("Failed to stat home directory %s: %s", h, pa_cstrerror(errno)); - return NULL; + goto out; } if (st.st_uid != getuid()) { pa_log_error("Home directory %s not ours.", h); errno = EACCES; - return NULL; + goto out; } - return pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h); + ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h); + +out: + pa_xfree(h); + return ret; } char *pa_get_state_dir(void) { @@ -1561,15 +1577,32 @@ if (local) { const char *e; char *lfn; - char h[PATH_MAX]; FILE *f; if ((e = getenv("PULSE_CONFIG_PATH"))) fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local); - else if (pa_get_home_dir(h, sizeof(h))) + else { + char *h; + size_t allocated = 128; + + while (1) { + h = pa_xmalloc(allocated); + + if (!pa_get_home_dir(h, allocated)) { + pa_xfree(h); + return NULL; + } + + if (strlen(h) < allocated - 1) + break; + + pa_xfree(h); + allocated *= 2; + } + fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse" PA_PATH_SEP "%s", h, local); - else - return NULL; + pa_xfree(h); + } #ifdef OS_IS_WIN32 if (!ExpandEnvironmentStrings(lfn, buf, PATH_MAX)) { @@ -1648,14 +1681,31 @@ if (local) { const char *e; char *lfn; - char h[PATH_MAX]; if ((e = getenv("PULSE_CONFIG_PATH"))) fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local); - else if (pa_get_home_dir(h, sizeof(h))) + else { + char *h; + size_t allocated = 128; + + while (1) { + h = pa_xmalloc(allocated); + + if (!pa_get_home_dir(h, allocated)) { + pa_xfree(h); + return NULL; + } + + if (strlen(h) < allocated - 1) + break; + + pa_xfree(h); + allocated *= 2; + } + fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse" PA_PATH_SEP "%s", h, local); - else - return NULL; + pa_xfree(h); + } #ifdef OS_IS_WIN32 if (!ExpandEnvironmentStrings(lfn, buf, PATH_MAX)) { --- src/pulsecore/proplist-util.c.orig 2009-04-19 17:07:42.000000000 +0000 +++ src/pulsecore/proplist-util.c 2009-04-19 17:10:05.000000000 +0000 @@ -186,12 +186,27 @@ } if (!pa_proplist_contains(p, PA_PROP_APPLICATION_PROCESS_BINARY)) { - char t[PATH_MAX]; - if (pa_get_binary_name(t, sizeof(t))) { - char *c = pa_utf8_filter(t); - pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c); - pa_xfree(c); + char *t; + size_t allocated = 128; + + while (1) { + t = pa_xmalloc(allocated); + + if (!pa_get_binary_name(t, allocated)) + break; + + if (strlen(t) < allocated - 1) { + char *c = pa_utf8_filter(t); + pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c); + pa_xfree(c); + break; + } + + pa_xfree(t); + allocated *= 2; } + + pa_xfree(t); } add_glib_properties(p); --- ./src/pulsecore/core-scache.c.orig 2009-03-31 02:26:15.740000000 +0100 +++ ./src/pulsecore/core-scache.c 2009-03-31 02:49:59.250000000 +0100 @@ -487,16 +487,25 @@ #endif } else { struct dirent *e; + size_t allocated = 128; + char *p = pa_xmalloc(allocated); while ((e = readdir(dir))) { - char p[PATH_MAX]; - if (e->d_name[0] == '.') continue; - pa_snprintf(p, sizeof(p), "%s/%s", pathname, e->d_name); - add_file(c, p); + while (1) { + if (pa_snprintf(p, allocated, "%s/%s", pathname, e->d_name) < allocated - 1) { + add_file(c, p); + break; + } + + pa_xfree(p); + allocated *= 2; + p = pa_xmalloc(allocated); + } } + pa_xfree(p); closedir(dir); } --- ./src/utils/padsp.c.orig 2009-03-31 02:24:59.120000000 +0100 +++ ./src/utils/padsp.c 2009-03-31 03:14:08.930000000 +0100 @@ -459,16 +459,31 @@ } static const char *client_name(char *buf, size_t n) { - char p[PATH_MAX]; + char *p; const char *e; + size_t allocated = 128; if ((e = getenv("PADSP_CLIENT_NAME"))) return e; - if (pa_get_binary_name(p, sizeof(p))) - snprintf(buf, n, "OSS Emulation[%s]", p); - else - snprintf(buf, n, "OSS"); + while(1) { + p = pa_xmalloc(allocated); + + if (!pa_get_binary_name(p, allocated)) { + snprintf(buf, n, "OSS"); + break; + } + + if (strlen(p) < allocated - 1) { + snprintf(buf, n, "OSS Emulation[%s]", p); + break; + } + + pa_xfree(p); + allocated *= 2; + } + + pa_xfree(p); return buf; } --- ./src/utils/pactl.c.orig 2009-03-31 02:24:53.220000000 +0100 +++ ./src/utils/pactl.c 2009-03-31 03:17:06.270000000 +0100 @@ -698,7 +698,6 @@ int main(int argc, char *argv[]) { pa_mainloop* m = NULL; - char tmp[PATH_MAX]; int ret = 1, r, c; char *server = NULL, *client_name = NULL, *bn; @@ -780,9 +779,9 @@ f = argv[optind]; n = strcspn(f, "."); - strncpy(tmp, f, n); - tmp[n] = 0; - sample_name = pa_xstrdup(tmp); + sample_name = pa_xmalloc(n + 1); + memcpy(sample_name, f, n); + sample_name[n] = 0; } memset(&sfinfo, 0, sizeof(sfinfo)); --- ./src/tests/get-binary-name-test.c.orig 2009-03-31 02:25:15.650000000 +0100 +++ ./src/tests/get-binary-name-test.c 2009-03-31 03:19:26.980000000 +0100 @@ -25,10 +25,24 @@ #include <stdio.h> #include <pulse/util.h> +#include <pulse/xmalloc.h> int main(int argc, char *argv[]) { - char exename[PATH_MAX]; + char *exename; + size_t allocated = 128; - printf("%s\n", pa_get_binary_name(exename, sizeof(exename))); + while (1) { + exename = pa_xmalloc(allocated); + + pa_get_binary_name(exename, allocated); + + if (strlen(exename) < allocated - 1) { + printf("%s\n", exename); + break; + } + + pa_xfree(exename); + allocated *= 2; + } return 0; } --- src/modules/module-pipe-sink.c.orig 2009-03-31 04:21:20.180000000 +0100 +++ src/modules/module-pipe-sink.c 2009-03-31 04:22:27.050000000 +0100 @@ -120,7 +120,11 @@ pa_assert(u); if (u->memchunk.length <= 0) +#ifdef PIPE_BUF pa_sink_render(u->sink, PIPE_BUF, &u->memchunk); +#else + pa_sink_render(u->sink, SIZE_MAX, &u->memchunk); +#endif pa_assert(u->memchunk.length > 0); --- src/modules/module-pipe-source.c.orig 2009-03-31 04:24:14.940000000 +0100 +++ src/modules/module-pipe-source.c 2009-03-31 04:25:06.670000000 +0100 @@ -141,7 +141,11 @@ void *p; if (!u->memchunk.memblock) { +#ifdef PIPE_BUF u->memchunk.memblock = pa_memblock_new(u->core->mempool, PIPE_BUF); +#else + u->memchunk.memblock = pa_memblock_new(u->core->mempool, -1); +#endif u->memchunk.index = u->memchunk.length = 0; } --- debian/rules.orig 2009-03-31 04:51:50.800000000 +0100 +++ debian/rules 2009-03-31 04:52:05.140000000 +0100 @@ -7,6 +7,8 @@ common-build-arch:: grep -v -e alsa -e evdev debian/pulseaudio.install > \ + debian/pulseaudio.install.hurd-i386 + grep -v -e alsa -e evdev debian/pulseaudio.install > \ debian/pulseaudio.install.kfreebsd-i386 grep -v -e alsa -e evdev debian/pulseaudio.install > \ debian/pulseaudio.install.kfreebsd-amd64 @@ -19,6 +21,7 @@ common-binary-post-install-arch:: list-missing clean:: + rm -f debian/pulseaudio.install.hurd-i386 rm -f debian/pulseaudio.install.kfreebsd-i386 rm -f debian/pulseaudio.install.kfreebsd-amd64