From 5dd99bb0a6f90b16d51863551f64f6f7e71ecebb Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 15 Mar 2026 09:47:58 +0000 Subject: [PATCH] bootstrap: tar: fix pointer-alignment tar parsing issue --- sys/bootstrap/tar.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/bootstrap/tar.c b/sys/bootstrap/tar.c index 966b03a..7be6544 100644 --- a/sys/bootstrap/tar.c +++ b/sys/bootstrap/tar.c @@ -74,8 +74,10 @@ int tar_open(struct tar *tar, const char *path, struct tar_file *out) } s += header.size; - s += ((sizeof *bin_header) - - ((uintptr_t)s % (sizeof *bin_header))); + if ((uintptr_t)s % (sizeof *bin_header)) { + s += ((sizeof *bin_header) + - ((uintptr_t)s % (sizeof *bin_header))); + } bin_header = (struct tar_bin_header *)s; } @@ -382,8 +384,10 @@ static enum fs_status build_dentry_tree( } s += header.size; - s += ((sizeof *bin_header) - - ((uintptr_t)s % (sizeof *bin_header))); + if ((uintptr_t)s % (sizeof *bin_header)) { + s += ((sizeof *bin_header) + - ((uintptr_t)s % (sizeof *bin_header))); + } bin_header = (struct tar_bin_header *)s; }