]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use stat_verify_regular() more
authorLennart Poettering <lennart@amutable.com>
Mon, 13 Apr 2026 09:09:25 +0000 (11:09 +0200)
committerLennart Poettering <lennart@amutable.com>
Mon, 13 Apr 2026 11:20:43 +0000 (13:20 +0200)
src/basic/locale-util.c
src/shared/hibernate-util.c

index 11e91ab8345051c639adacabed1a2d4236fd02ce..3b869d70f9747ea81923996547698da5842f9631 100644 (file)
@@ -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;
index c141cdc8c6701a9015bbee3bf083cb9e23d1d6ba..f9e095f27384d2bd495caa98a8415e04d6e3f232 100644 (file)
@@ -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 */