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) ...@@ -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, //pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_BINARY,
// PACKAGE_NAME); // PACKAGE_NAME);
char buf[sysconf (_SC_GETPW_R_SIZE_MAX)]; for (size_t max = sysconf (_SC_GETPW_R_SIZE_MAX), len = max % 1024 + 1024;
struct passwd pwbuf, *pw; len < max; len += 1024)
{
if (getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw) == 0 struct passwd pwbuf, *pw;
&& pw != NULL) char buf[len];
pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_USER,
pw->pw_name); if (getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw) == 0
&& pw != NULL)
char hostname[sysconf (_SC_HOST_NAME_MAX)]; pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_USER,
if (gethostname (hostname, sizeof (hostname)) == 0) pw->pw_name);
pa_proplist_sets (props, PA_PROP_APPLICATION_PROCESS_HOST, }
hostname);
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"); const char *session = getenv ("XDG_SESSION_COOKIE");
if (session != NULL) 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