We already have the stat data, let's actually check if things are
alright before relying on .st_size
#include "io-util.h"
#include "log.h"
#include "memory-util.h"
+#include "stat-util.h"
#include "string-util.h"
#include "time-util.h"
#include "utf8.h"
void **ret_value,
size_t *ret_size) {
+ int r;
usec_t begin = 0; /* Unnecessary initialization to appease gcc */
assert(variable);
if (fstat(fd, &st) < 0)
return log_debug_errno(errno, "fstat(\"%s\") failed: %m", p);
+ r = stat_verify_regular(&st);
+ if (r < 0)
+ return log_debug_errno(r, "EFI variable '%s' is not a regular file, refusing: %m", p);
+
if (st.st_size == 0) /* for uncommited variables, see below */
return log_debug_errno(SYNTHETIC_ERRNO(ENOENT), "EFI variable '%s' is uncommitted", p);
if ((uint64_t) st.st_size < sizeof(attr))