GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Integer overflow in msgpack_unpacker_expand_buffer() causes false-success undersized reservation · Issue #1181 · msgpack/msgpack-c

Integer overflow in msgpack_unpacker_expand_buffer() causes false-success undersized reservation #1181

New issue
Copy link
New issue
Copy link
Closed
Closed
Integer overflow in msgpack_unpacker_expand_buffer() causes false-success undersized reservation#1181
Copy link

Description

@mtholmquist
mtholmquist
opened on Aug 13, 2026
Issue body actions

msgpack_unpacker_reserve_buffer(mpac, size) can return true while the buffer has far less than size bytes free.

In msgpack_unpacker_expand_buffer() (src/unpack.c:444-462), the loop target size + mpac->used wraps size_t when size is near SIZE_MAX. The doubling loop exits at the pre-wrap starting value, realloc() succeeds at that small size, and the function returns true unconditionally — no post-condition check.

Reproducer (64-bit, tag c-7.0.1):

msgpack_unpacker mpac;
msgpack_unpacker_init(&mpac, 8);

size_t request = SIZE_MAX - 2;
bool ok = msgpack_unpacker_reserve_buffer(&mpac, request);
// ok == true

size_t actual = msgpack_unpacker_buffer_capacity(&mpac);
// actual == 12  (vs. requested ~1.8e19)

A caller trusting the true return and writing up to the requested size overflows the heap buffer. ASan confirms heap-buffer-overflow WRITE at the memcpy into msgpack_unpacker_buffer(). A Release build (-O2 -DNDEBUG) hits glibc's double free or corruption (out) on the same path.

The library's own example/lib_buffer_unpack.c teaches the exact reserve-then-write pattern, with a defensive assert(buffer_capacity >= request) that compiles away under NDEBUG.

This is the same doubling-loop overflow shape that PRs #547/#550 (2017), #733 (2018), and #776/#792 (2019) fixed in sibling functions. expand_buffer() was not included in any of those fixes.

Suggested fix: check size > SIZE_MAX - mpac->used before the addition, or add a post-condition check (next_size - mpac->used >= size) before returning true.

Confirmed on c-7.0.1 (commit 1be50ee) and c_master HEAD.

Reacted by Takatoshi Kondo

Activity

  1. redboltz commented on Aug 14, 2026

    @redboltz
    redboltz
    on Aug 14, 2026
    Contributor
    More actions

    @mtholmquist , Thank you for reporting this issue. I am currently away for summer break and will look into it around August 25th.

  2. carnil commented on Aug 21, 2026

    @carnil
    carnil
    on Aug 21, 2026
    More actions

    Looks this got a CVE assigned: CVE-2026-72854

  3. redboltz
    added 2 commits that reference this issue on Aug 25, 2026

    Fix msgpack#1181

    This issue will close once commit 8a48af0 is merged into the 'master' branch.
    8a48af0

    Merge pull request #1182 from redboltz/fix_1181

    This issue will close once commit e17beb3 is merged into the 'master' branch.
    e17beb3
  4. redboltz commented on Aug 25, 2026

    @redboltz
    redboltz
    on Aug 25, 2026
    Contributor
    More actions

    Fixed by #1182

  5. redboltz
    closed this as completedon Aug 25, 2026
  6. halstead
    added a commit that references this issue on Oct 1, 2026

    msgpack-c: patch CVE-2026-72854

    6a48592
  7. halstead
    added a commit that references this issue on Oct 12, 2026

    msgpack-c: patch CVE-2026-72854

    53f2c85
  8. jpuhlman
    added a commit that references this issue on Oct 27, 2026

    msgpack-c: patch CVE-2026-72854

    bc17e48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.