Skip to content

Fix integer overflow in ptp_canon_getobjectinfo()#396

Open
lzwind wants to merge 1 commit into
libmtp:masterfrom
lzwind:fix/issue-369-integer-overflow
Open

Fix integer overflow in ptp_canon_getobjectinfo()#396
lzwind wants to merge 1 commit into
libmtp:masterfrom
lzwind:fix/issue-369-integer-overflow

Conversation

@lzwind

@lzwind lzwind commented Jun 3, 2026

Copy link
Copy Markdown

Summary

A malicious PTP device can control Param1 and size to trigger an undersized allocation followed by heap overflow.

Test plan

  • Verify compilation passes
  • Review that the overflow guard is placed before the existing calloc() call
  • Confirm existing Param1 > size/PTP_CANON_FolderEntryLen check remains intact

Add overflow check before calloc to prevent heap-based buffer
overflow when a malicious PTP device provides a large Param1
value that wraps around SIZE_MAX.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer Overflow in ptp_canon_getobjectinfo() Leading to Heap-Based Buffer Overflow

1 participant