audio/paaudio: avoid pidfile path truncation
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: Hui Peng <benquike@gmail.com>
Fixes: d175505bd6 ("audio: check for pulseaudio daemon pidfile")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261004-issue-4560-v1-5-ccbef537cbeb@redhat.com>
This commit is contained in:
1 parent
2fdcaaf0fd
commit
c826f7d25c
1 file changed
+2
-2
+2
-2
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user