Commit 191f0716 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

PulseAudio: do not assume sysconf() returns a finite value

(Here -1 means infinity.)
parent 4e70b523
......@@ -117,18 +117,27 @@ pa_context *vlc_pa_connect (vlc_object_t *obj, pa_threaded_mainloop **mlp)
//pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_BINARY,
// PACKAGE_NAME);
char buf[sysconf (_SC_GETPW_R_SIZE_MAX)];
struct passwd pwbuf, *pw;
if (getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw) == 0
&& pw != NULL)
pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_USER,
pw->pw_name);
char hostname[sysconf (_SC_HOST_NAME_MAX)];
if (gethostname (hostname, sizeof (hostname)) == 0)
pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_HOST,
hostname);
for (size_t max = sysconf (_SC_GETPW_R_SIZE_MAX), len = max % 1024 + 1024;
len < max; len += 1024)
{
struct passwd pwbuf, *pw;
char buf[len];
if (getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw) == 0
&& pw != NULL)
pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_USER,
pw->pw_name);
}
for (size_t max = sysconf (_SC_HOST_NAME_MAX), len = max % 1024 + 1024;
len < max; len += 1024)
{
char hostname[len];
if (gethostname (hostname, sizeof (hostname)) == 0)
pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_HOST,
hostname);
}
const char *session = getenv ("XDG_SESSION_COOKIE");
if (session != NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment