lbutils env_tmpdir: use static strings for fallback

i currently return pointers to these, without copying.

they can fade because of this. make them static, since that
is what they should be anyway.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-28 09:06:17 +00:00
parent 6643d9c1fa
commit c4ff9e5763
+8 -8
View File
@@ -206,8 +206,8 @@ env_tmpdir(int bypass_all_sticky_checks, char **tmpdir,
int allow_noworld_unsticky; int allow_noworld_unsticky;
int saved_errno = errno; int saved_errno = errno;
char tmp[] = "/tmp"; static const char tmp[] = "/tmp";
char vartmp[] = "/var/tmp"; static const char vartmp[] = "/var/tmp";
/* tmpdir is a user override, if set */ /* tmpdir is a user override, if set */
if (override_tmpdir == NULL) if (override_tmpdir == NULL)
@@ -238,26 +238,26 @@ env_tmpdir(int bypass_all_sticky_checks, char **tmpdir,
allow_noworld_unsticky = 0; allow_noworld_unsticky = 0;
if (world_writeable_and_sticky("/tmp", if (world_writeable_and_sticky(tmp,
allow_noworld_unsticky, allow_noworld_unsticky,
bypass_all_sticky_checks)) { bypass_all_sticky_checks)) {
if (tmpdir != NULL) if (tmpdir != NULL)
*tmpdir = tmp; *tmpdir = (char *)tmp;
errno = saved_errno; errno = saved_errno;
return "/tmp"; return (char *)tmp;
} }
if (world_writeable_and_sticky("/var/tmp", if (world_writeable_and_sticky(vartmp,
allow_noworld_unsticky, allow_noworld_unsticky,
bypass_all_sticky_checks)) { bypass_all_sticky_checks)) {
if (tmpdir != NULL) if (tmpdir != NULL)
*tmpdir = vartmp; *tmpdir = (char *)vartmp;
errno = saved_errno; errno = saved_errno;
return "/var/tmp"; return (char *)vartmp;
} }
return NULL; return NULL;