# CVE-2026-40339: libgphoto2 has OOB read in ptp_unpack_Sony_DPD() FormFlag 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:42:32.586Z
- Modified: 2026-10-25T23:10:00.167Z
- 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 `ptp_unpack_Sony_DPD()` in `camlibs/ptp2/ptp-pack.c` (line 842). The function reads the FormFlag byte via `dtoh8o(data, *poffset)` without a prior bounds check. The standard `ptp_unpack_DPD()` at lines 686–687 correctly validates `*offset + sizeof(uint8_t) > dpdlen` before this same read, but the Sony variant omits this check entirely. Commit 09f8a940b1e418b5693f5c11e3016a1ad2cea62d fixes the issue.

(As written by CVE List.)

## Affected

- gphoto libgphoto2: <= 2.5.33

## References

- <https://github.com/gphoto/libgphoto2/security/advisories/GHSA-42cm-m9hc-r7q8>
- <https://github.com/gphoto/libgphoto2/commit/09f8a940b1e418b5693f5c11e3016a1ad2cea62d>

## Sources

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

---

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