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.
{
"cwe_ids": [
"CWE-125"
],
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/40xxx/CVE-2026-40339.json",
"cna_assigner": "GitHub_M"
}"2026-07-21T23:32:05Z"
[
{
"signature_type": "Function",
"target": {
"file": "camlibs/ptp2/ptp-pack.c",
"function": "ptp_unpack_Sony_DPD"
},
"deprecated": false,
"source": "https://github.com/gphoto/libgphoto2/commit/09f8a940b1e418b5693f5c11e3016a1ad2cea62d",
"id": "CVE-2026-40339-3b42a887",
"signature_version": "v1",
"digest": {
"function_hash": "96800853065275638778436644108844897536",
"length": 4248.0
}
},
{
"signature_type": "Line",
"target": {
"file": "camlibs/ptp2/ptp-pack.c"
},
"deprecated": false,
"source": "https://github.com/gphoto/libgphoto2/commit/09f8a940b1e418b5693f5c11e3016a1ad2cea62d",
"id": "CVE-2026-40339-854fd3f4",
"signature_version": "v1",
"digest": {
"line_hashes": [
"150045175810682455768180707033109754229",
"157310575779410390658294844073745413854",
"232103645227817086041675545705809225954",
"51195960220326945294876332022813588033",
"317063548928842063853640988915940179683"
],
"threshold": 0.9
}
}
]
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-40339.json"