Skip to content

Commit fb24392

Browse files
committed
Fix mapped file leak on invalid avmpack open
The generic_unix invalid-pack rejection in sys_open_avm_from_file returned without releasing the mapping, leaking it and its file descriptor. Pre-existing, but truncated packs now take this path. Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent e211a5b commit fb24392

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9494
- Fixed AVM pack lookups not finding sections placed after a data file
9595
- Fixed an out-of-bounds read crashing the VM on an AVM pack section lookup miss (e.g. `atomvm:read_priv/2` for an unpacked file)
9696
- Fixed truncated or oversized AVM packs being accepted; they are now rejected at load instead of failing late
97+
- Fixed generic_unix leaking the file mapping when rejecting an invalid `.avm` file
9798

9899
## [0.7.0-alpha.1] - 2026-04-06
99100

src/platforms/generic_unix/lib/sys.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ enum OpenAVMResult sys_open_avm_from_file(
436436
return AVM_OPEN_CANNOT_OPEN;
437437
}
438438
if (UNLIKELY(!avmpack_is_complete(mapped->mapped, (uint32_t) mapped->size))) {
439+
mapped_file_close(mapped);
439440
return AVM_OPEN_INVALID;
440441
}
441442

0 commit comments

Comments
 (0)