minipaxtar is a small, freestanding C library for reading and writing POSIX PAX and USTAR tar archives. It is distributed under the MIT license.
It was designed as a safe, modern alternative to legacy lightweight tar libraries like microtar. Many existing micro-libraries lack defensive parsing, making them vulnerable to memory corruption or infinite loops when handling malformed input. minipaxtar provides strict bounds checking and robust error handling while keeping a minimal binary footprint.
-
⏩ Overview & Getting Started:
-
📘 Guides & Configuration:
-
⚙️ API Reference:
- Simple Integration: Available as both a standard
.c/.hfile pair and a single-header (stb-style) distribution. - Very Lightweight: ~7 KB for read-only or write-only builds, ~14 KB for full functionality.
- Portable: Compiles cleanly across mainstream and minimal compilers, including
GCC,Clang,MSVC,TCC, andchibicc. - Broad C Support: Full compatibility from C89 through modern C drafts (like C2Y).
- Defensive Safety: Thorough input validation, safe integer arithmetic, and defensive memory lifetime tracking.
- 100% Freestanding: Zero standard library dependencies (
MPTAR_NO_STD). Custom I/O and memory routines are passed explicitly through user configurations.
minipaxtar is designed to adapt to any C build system or project layout:
- CMake Integration: Fetch or include via
add_subdirectory()orFetchContent. - Manual Drop-in: Add
minipaxtar.candminipaxtar.hdirectly to your source tree. - Single-Header Mode (
stb-style): Includeminipaxtar.hanywhere, and instantiate the implementation in exactly one C source file:
#define MINIPAXTAR_IMPLEMENTATION
#include "minipaxtar.h"- Zero Implicit Allocation:
minipaxtarnever callsmallocor system allocators internally unless you explicitly supply allocation callbacks in reader/writer contexts. - Clean Lifetime Control: Metadata allocations are isolated and cleared defensively (
mptar_reader_free_metadata). Pointers are reset toNULLupon being freed, preventing double-free errors even during complex error-recovery paths. - State Safety: Read and write contexts maintain clear offset tracking, avoiding out-of-bounds reads on truncated or corrupt archive headers.
minipaxtar was created as a modern, safe replacement for microtar, which has been unmaintained since 2017 and suffers from severe limits and security vulnerabilities.
| Feature / Property | microtar |
minipaxtar |
|---|---|---|
| Security Status | Vulnerable (CVE-2026-43623) | Defensive design, strict bounds checking |
| Standard Support | Basic V7 / Custom subset | USTAR, POSIX PAX, GNU binary extensions |
| Max Filename Length | 100 bytes (No prefix field) | Unlimited via PAX extended headers |
| Max File Size | 4 GB limit (unsigned 32-bit size) |
Near-unlimited (Full 64-bit uint64_t support) |
| Standard Library Reliance | Heavily Coupled | Fully decoupled (MPTAR_NO_STD) |
| Zero-Copy Skipping | Requires seek/read operations | Instant offset and byte tracking |
| Write API Size | ~5.2 KB | ~6.3 KB |
For a deep dive into code differences, API mechanics, and architectural breakdowns, see COMPARISON.md.
This project is licensed under the MIT License. See the LICENSE file for details.