Merge branch 'jk/pack-header-parse-alignment-fix'

It was possible for "git unpack-objects" and "git index-pack" to
make an unaligned access, which has been corrected.

* jk/pack-header-parse-alignment-fix:
  index-pack, unpack-objects: use skip_prefix to avoid magic number
  index-pack, unpack-objects: use get_be32() for reading pack header
  parse_pack_header_option(): avoid unaligned memory writes
  packfile: factor out --pack_header argument parsing
  bswap.h: squelch potential sparse -Wcast-truncate warnings
This commit is contained in:
Junio C Hamano
2025-01-28 13:02:23 -08:00
6 changed files with 64 additions and 50 deletions

3
pack.h
View File

@ -13,7 +13,8 @@ struct repository;
*/
#define PACK_SIGNATURE 0x5041434b /* "PACK" */
#define PACK_VERSION 2
#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
#define pack_version_ok(v) pack_version_ok_native(ntohl(v))
#define pack_version_ok_native(v) ((v) == 2 || (v) == 3)
struct pack_header {
uint32_t hdr_signature;
uint32_t hdr_version;