Xar has no standard that says what makes an archive valid, so the rules are what the three readers
check. This page lists them, read on 2026-11-19 from libxar
(mackyle/xar: archive.c, signature.c,
hash.c, xar.h), libarchive (archive_read_support_format_xar.c) and 7-Zip
(XarHandler.cpp). The explorer lists every one of them as a problem, naming the reader that stops
at it, and a damaged archive is still shown as far as it reads. An empty cell means the reader has no such check.
Header
| Rule | libxar | libarchive | 7-Zip |
|---|---|---|---|
The file starts xar! | refuses | refuses | refuses |
| Header size under 28 | refuses | refuses | refuses |
| Header size over 28 | skips the extra bytes (reads the digest name when the algorithm is 3) | refuses: only exactly 28 | skips them, up to 64 bytes in all |
| Version not 1 | does not check it | refuses: “Unsupported header version” | accepts 0, refuses above 1 |
| Header checksum algorithm code not known (above 3 for libxar, for example 4, 5 or 99) | prints “Unknown hashing algorithm, skipping”, then refuses: “Checksum style mismatch!” (archive.c: a code other than 0 to 3 never matches the table of contents’ style) | refuses above 4 | no table of contents check |
| Digest name not known to OpenSSL (header codes 1 to 3) | prints “Unknown hashing algorithm, skipping” and goes on: no table of contents check | ||
| Algorithm 3 with a header of 32 bytes or more: size not a multiple of 4, or no NUL-terminated name inside the header | refuses | ||
Algorithm 3 named none or empty; named sha1 or md5 | must not be (xar.h) | ||
| Compressed table of contents runs past the end of the file | “Truncated archive file” | ||
| Inflated table of contents not the header’s uncompressed length | “TOC uncompressed size error” | refuses | |
| NUL byte in the XML | refuses |
Algorithm 3 means SHA-256 in macOS’s own xar (1.8dev), libarchive and 7-Zip, in a 28-byte header, and 4 means
SHA-512: see Checksums and signature. 7-Zip
says it does not support a digest named in the header.
Table of contents and its checksum
| Rule | libxar | libarchive | 7-Zip |
|---|---|---|---|
| The XML is not well-formed | refuses | refuses | refuses |
The document element is xar, with toc as its only child | skips unknown elements | refuses otherwise | |
The header’s algorithm and <checksum style> name the same digest (header “none”: no style or “none”) | refuses: “Checksum style mismatch!” | ||
| A signature needs a checksum (header algorithm not 0) | refuses: “Checksum/signature mismatch!” (printed only for a signature with header algorithm 0) | ||
A signature needs the checksum’s offset and size | refuses without a message: xar_open returns NULL (archive.c) | ||
The checksum’s size is the digest’s length | refuses, but only when OpenSSL knows the header’s digest (the block is skipped otherwise) | ||
The checksum is at offset (normally 0) | follows it | follows it | assumes 0 |
| The digest of the compressed table of contents matches the checksum in the heap | refuses: “Checksums do not match!” | refuses: “Checksum error” | flags an error, still lists the files |
Files, encodings and the heap
| Rule | libxar | libarchive | 7-Zip |
|---|---|---|---|
offset, length, size are decimal numbers | reads the digits at the start of the text | refuses the archive | |
A file has a name | an empty path | ||
A name has no .. component, is not absolute and is not . or .. | xar_extract uses the file’s path as it is: no check in that function (read raw; the macOS binary was not run on such a name) | the xar reader passes the name on unchanged; the disk writer (archive_write_disk_posix.c) refuses .. and absolute paths only when the caller sets ARCHIVE_EXTRACT_SECURE_NODOTDOT or ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS, and otherwise keeps the .. elements | |
A file has a type from the list: file, hardlink, directory, symlink, character special, block special, socket, fifo | reads another value as a regular file | ||
mode is octal digits | reads the digits at the start | takes a mode only if it starts with 0 and is all octal | |
A time is YYYY-MM-DDTHH:MM:SSZ, exactly 20 characters | reads another form as 0 (1970) | ||
A hard link (<type link="id">) names a file whose <type link="original"> has that id; a file has one link attribute | leaves an unmatched link alone; two link attributes: “File with multiple link attributes”, refuses | ||
The encoding style is one of application/octet-stream, x-gzip (zlib data), x-bzip2, x-lzma, x-xz | also application/zlib | reads another style as stored | decodes stored, zlib (also application/zlib) and bzip2 only; other styles are “unsupported method” |
A stored member’s length equals its size | “Decompressed size error” | “unsupported method” | |
The decoded bytes are size long | “Decompressed size error” | ||
| The archived and extracted checksums match the stored and decoded bytes | compares only the archived-checksum, on extraction (“archived-checksum message digest hash values do not match”, and only for a digest OpenSSL knows); the extracted digest is finalised and discarded (hash.c, xar_hash_out_done) | “Checksum error” | keeps them as properties; a hex string of the wrong length or an unknown style is marked as an error |
| A checksum is whole bytes of hexadecimal | reads less, so the check fails | marks an error | |
An extended attribute has a name | “Xattr name error” | ||
| The stored bytes are all in the file | “Truncated archive file” |
Some things no reader checks, and the explorer shows without calling them errors: heap bytes that nothing in
the table of contents points to (readers skip them; 7-Zip takes the end of the last object as the end of the archive), and
two objects that share heap bytes (libxar never writes that, but nothing refuses it; the explorer notes it).
macOS’s package tools write every file’s name twice with the same text, and the readers use the first.