]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkfs.cramfs: Improve file size check
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 18 Apr 2026 15:21:48 +0000 (17:21 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 18 Apr 2026 15:21:48 +0000 (17:21 +0200)
Check st.st_size (off_t) for actual file size instead of the possibly
already truncated entry->size (unsigned int) value. Otherwise files
larger than 4 GB might be silently truncated.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
disk-utils/mkfs.cramfs.c

index 2d57900b7744736b50950c26a2fed4bd4425f4e0..13c93e3a433d9194f9cd7e69ab5f68cd7aa3a134 100644 (file)
@@ -363,7 +363,7 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
                        entry->size = parse_directory(root_entry, path, &entry->child, fslen_ub);
                } else if (S_ISREG(st.st_mode)) {
                        entry->path = xstrdup(path);
-                       if (entry->size >= (1 << CRAMFS_SIZE_WIDTH)) {
+                       if (st.st_size >= (1 << CRAMFS_SIZE_WIDTH)) {
                                warn_size = 1;
                                entry->size = (1 << CRAMFS_SIZE_WIDTH) - 1;
                        }