vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <[email protected]> | Mon Aug 13 22:09:50 2012 +0300| [6f1bad2aeacfde77e8ddcde1fc333825014334f8] | committer: Rémi Denis-Courmont
PulseAudio: do not assume sysconf() returns a finite value (Here -1 means infinity.) (cherry picked from commit 191f071695d272e99de17787d33e773606656430) > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=6f1bad2aeacfde77e8ddcde1fc333825014334f8 --- modules/audio_output/vlcpulse.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/audio_output/vlcpulse.c b/modules/audio_output/vlcpulse.c index 4b6465c..e4c35e1 100644 --- a/modules/audio_output/vlcpulse.c +++ b/modules/audio_output/vlcpulse.c @@ -107,18 +107,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) _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
