mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 04:22:15 +02:00
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:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user