mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
pulse-server: fix potential use of dangling pointer
`getpwuid_r()` puts the strings pointed to from the returned passwd struct into the specified buffer. Previously, that buffer technically didn't live long enough to be usable in the `snprintf()` call - although in practice this didn't appear to be a problem. A particular version of GCC 11 generates the same machine code for this function regardless whether this patch is applied or not. Still, fix this by moving the buffer to an outer scope.
This commit is contained in:
parent
6af1388d66
commit
67b422fa18
1 changed files with 1 additions and 1 deletions
|
|
@ -55,6 +55,7 @@ int get_runtime_dir(char *buf, size_t buflen, const char *dir)
|
|||
{
|
||||
const char *runtime_dir;
|
||||
struct stat stat_buf;
|
||||
char buffer[4096];
|
||||
int res, size;
|
||||
|
||||
runtime_dir = getenv("PULSE_RUNTIME_PATH");
|
||||
|
|
@ -64,7 +65,6 @@ int get_runtime_dir(char *buf, size_t buflen, const char *dir)
|
|||
runtime_dir = getenv("HOME");
|
||||
if (runtime_dir == NULL) {
|
||||
struct passwd pwd, *result = NULL;
|
||||
char buffer[4096];
|
||||
if (getpwuid_r(getuid(), &pwd, buffer, sizeof(buffer), &result) == 0)
|
||||
runtime_dir = result ? result->pw_dir : NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue