[git commit] cpio: error out if the file to be achived is >=4GB

Denys Vlasenko vda.linux at googlemail.com
Mon Apr 21 02:42:33 UTC 2025


commit: https://git.busybox.net/busybox/commit/?id=5f07327251c93184dfcfc8d978fc35705930ec53
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
.rodata                                           105715  105751     +36
cpio_o                                              1145    1167     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 58/0)               Total: 58 bytes

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 archival/cpio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/archival/cpio.c b/archival/cpio.c
index f0d990048..7b01ee3a2 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -350,6 +350,12 @@ static NOINLINE int cpio_o(void)
 			st.st_dev = st.st_rdev = 0;
 #endif
 
+		if (sizeof(st.st_size) > 4
+		 && st.st_size > (off_t)0xffffffff
+		) {
+			bb_error_msg_and_die("error: file '%s' is larger than 4GB", name);
+		}
+
 		bytes += printf("070701"
 				"%08X%08X%08X%08X%08X%08X%08X"
 				"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */


More information about the busybox-cvs mailing list