On Fri, Jan 17, 2025 at 07:11:21AM -0500, Jeff King wrote: > Which certainly seems sketchy, though it is kind of interesting that it > has never been a problem before (and the code has been this way for > decades). At any rate, the fix is probably this (and we'd want the same > in index-pack, too, I'd think): Assuming that helps, here's a series which does that fix plus some associated cleanups. I'm curious if it's enough. After we write to this unaligned buffer, naturally the next thing we'll do is read from it, and the reading routines will do the same cast (see unpack_all() in unpack-objects). But maybe your platform allows unaligned reads but not writes? Probably I am being too optimistic. :) [1/3]: packfile: factor out --pack_header argument parsing [2/3]: parse_pack_header_option(): avoid unaligned memory writes [3/3]: index-pack, unpack-objects: use skip_prefix to avoid magic number builtin/index-pack.c | 18 +++++------------- builtin/unpack-objects.c | 18 +++++------------- packfile.c | 22 ++++++++++++++++++++++ packfile.h | 6 ++++++ 4 files changed, 38 insertions(+), 26 deletions(-) -Peff