mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 04:22:15 +02:00
util/nvmutil: harden pledge/unveil calls (OpenBSD)
*Open* files at the start, then unveil. The same overall behaviour is observed. In the case that invalid arguments are given, simply opening a file does not cause much performance impact (if any). Restrict operations as early as possible in code. Bonus: writeGbeFile also hardened; if flags is O_RDONLY, it aborts. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void readGbeFile(const char *path, int flags);
|
||||
void openFiles(const char *path);
|
||||
void readGbeFile(const char *path);
|
||||
void cmd_setmac(const char *strMac);
|
||||
int invalidMacAddress(const char *strMac, uint16_t *mac);
|
||||
uint8_t hextonum(char chs);
|
||||
@@ -42,7 +43,7 @@ uint8_t *buf = (uint8_t *) &buf16;
|
||||
size_t nf = 128, gbe[2];
|
||||
uint8_t skipread[2] = {0, 0};
|
||||
|
||||
int fd = -1, part, gbeFileModified = 0;
|
||||
int flags = O_RDWR, fd = -1, part, gbeFileModified = 0;
|
||||
uint8_t nvmPartModified[2] = {0, 0};
|
||||
|
||||
int test = 1;
|
||||
|
||||
Reference in New Issue
Block a user