mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
nvmutil tmpdir: check world-writeable / sticky bits
must be world writeable and not have sticky bits a bit theoretical, but we're also reading TMPDIR, which could be anything due to how this is called, it defaults back to /tmp if null is returned, so itt's safe Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -991,7 +991,7 @@ rlong(void)
|
|||||||
defined(__NetBSD__) || defined(__APPLE__)
|
defined(__NetBSD__) || defined(__APPLE__)
|
||||||
|
|
||||||
unsigned long rval;
|
unsigned long rval;
|
||||||
arc4random_buf(&rval, sizeof(unsigned long);
|
arc4random_buf(&rval, sizeof(unsigned long));
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
#else
|
#else
|
||||||
@@ -3001,8 +3001,8 @@ x_c_tmpdir(void)
|
|||||||
|
|
||||||
t = getenv("TMPDIR");
|
t = getenv("TMPDIR");
|
||||||
if (t && *t) {
|
if (t && *t) {
|
||||||
if (stat(t, &st) == 0 && S_ISDIR(st.st_mode))
|
if ((st.st_mode & S_IWOTH) && !(st.st_mode & S_ISVTX))
|
||||||
return t;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat("/tmp", &st) == 0 && S_ISDIR(st.st_mode))
|
if (stat("/tmp", &st) == 0 && S_ISDIR(st.st_mode))
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ int fchmod(int fd, mode_t mode);
|
|||||||
#define OFF_RESET 1
|
#define OFF_RESET 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_ISVTX
|
||||||
|
#define S_ISVTX 01000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(S_IFMT) && ((S_ISVTX & S_IFMT) != 0)
|
||||||
|
#error "Unexpected bit layout"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_ZERO_RW_RETRY
|
#ifndef MAX_ZERO_RW_RETRY
|
||||||
#define MAX_ZERO_RW_RETRY 5
|
#define MAX_ZERO_RW_RETRY 5
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user