# CVE-2026-40338: libgphoto2 has OOB read in ptp_unpack_Sony_DPD() enumeration count parsing in ptp-pack.c

- Severity: Medium 5.2 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:P/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:L`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.21%, higher than 11% of CVEs (2026-12-01)
- Published: 2026-04-17T23:40:10.097Z
- Modified: 2026-10-26T22:10:00.163Z
- Weaknesses: CWE-125
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: GitHub_M

## Description

libgphoto2 is a camera access and control library. Versions up to and including 2.5.33 have an out-of-bounds read in the PTP_DPFF_Enumeration case of `ptp_unpack_Sony_DPD()` in `camlibs/ptp2/ptp-pack.c` (line 856). The function reads a 2-byte enumeration count N via `dtoh16o(data, *poffset)` without verifying that 2 bytes remain in the buffer. The standard `ptp_unpack_DPD()` at line 704 has this exact check, confirming the Sony variant omitted it by oversight. Commit 3b9f9696be76ae51dca983d9dd8ce586a2561845 fixes the issue.

(As written by CVE List.)

## Affected

- gphoto libgphoto2: <= 2.5.33

## References

- <https://github.com/gphoto/libgphoto2/security/advisories/GHSA-2hwp-w84q-27hf>
- <https://github.com/gphoto/libgphoto2/commit/3b9f9696be76ae51dca983d9dd8ce586a2561845>

## Sources

- CVE List: [CVE-2026-40338](https://www.cve.org/CVERecord?id=CVE-2026-40338), CVE Terms of Use, modified 2026-04-20
- NVD: [CVE-2026-40338](https://nvd.nist.gov/vuln/detail/CVE-2026-40338), Public domain, modified 2026-10-26

---

Page: https://cve.day/CVE-2026-40338 · Whole record: https://cve.day/CVE-2026-40338.json · Rebuilt by cve.day 2026-11-25T22:59:18.982Z
