The pidfile path is built with snprintf() into a 64-byte stack buffer, which can silently truncate when XDG_RUNTIME_DIR is long. Use g_strdup_printf() with g_autofree instead.
Reported-by: Pavee Hui <[email protected]> Fixes: d175505bd68d ("audio: check for pulseaudio daemon pidfile") Signed-off-by: Marc-André Lureau <[email protected]> --- audio/paaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 9d0a622fc5e6..358595c0460e 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -819,7 +819,7 @@ audio_pa_realize(AudioBackend *abe, Audiodev *dev, Error **errp) } if (!popts->server) { - char pidfile[64]; + g_autofree char *pidfile = NULL; char *runtime; struct stat st; @@ -828,7 +828,7 @@ audio_pa_realize(AudioBackend *abe, Audiodev *dev, Error **errp) error_setg(errp, "XDG_RUNTIME_DIR not set"); return false; } - snprintf(pidfile, sizeof(pidfile), "%s/pulse/pid", runtime); + pidfile = g_strdup_printf("%s/pulse/pid", runtime); if (stat(pidfile, &st) != 0) { error_setg_errno(errp, errno, "could not stat pidfile %s", pidfile); return false; -- 2.56.0.rc0.29.g47ce80527c56
