From: Lennart Poettering Date: Mon, 13 Apr 2026 09:09:25 +0000 (+0200) Subject: tree-wide: use stat_verify_regular() more X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e0756c0b5e020dc8f8b53c3e69fffcb0892f599;p=thirdparty%2Fsystemd.git tree-wide: use stat_verify_regular() more --- diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 11e91ab8345..3b869d70f97 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -16,6 +16,7 @@ #include "path-util.h" #include "process-util.h" #include "set.h" +#include "stat-util.h" #include "string-table.h" #include "string-util.h" #include "strv.h" @@ -115,8 +116,9 @@ static int add_locales_from_archive(Set *locales) { if (fstat(fd, &st) < 0) return -errno; - if (!S_ISREG(st.st_mode)) - return -EBADMSG; + r = stat_verify_regular(&st); + if (r < 0) + return r; if (st.st_size < (off_t) sizeof(struct locarhead)) return -EBADMSG; diff --git a/src/shared/hibernate-util.c b/src/shared/hibernate-util.c index c141cdc8c67..f9e095f2738 100644 --- a/src/shared/hibernate-util.c +++ b/src/shared/hibernate-util.c @@ -37,14 +37,16 @@ int read_fiemap(int fd, struct fiemap **ret) { uint32_t result_extents = 0; uint64_t fiemap_start = 0, fiemap_length; const size_t n_extra = DIV_ROUND_UP(sizeof(struct fiemap), sizeof(struct fiemap_extent)); + int r; assert(fd >= 0); assert(ret); if (fstat(fd, &statinfo) < 0) return log_debug_errno(errno, "Cannot determine file size: %m"); - if (!S_ISREG(statinfo.st_mode)) - return -ENOTTY; + r = stat_verify_regular(&statinfo); + if (r < 0) + return r; fiemap_length = statinfo.st_size; /* Zero this out in case we run on a file with no extents */