new file mode 100644
@@ -0,0 +1,69 @@
+From 3674dbeafa5157a264ca5e562ffdbef159a2185f Mon Sep 17 00:00:00 2001
+From: Marcus Meissner <marcus@jet.franken.de>
+Date: Wed, 8 Apr 2026 15:28:52 +0200
+Subject: [PATCH] Fixed OOB read in ptp_unpack_EOS_FocusInfoEx
+
+Do not read out values before checking there is sufficient size
+
+CVE-2026-40341
+
+CVE: CVE-2026-40341
+Upstream-Status: Backport [https://github.com/gphoto/libgphoto2/commit/c385b34af260595dfbb5f9329526be5158985987]
+Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
+---
+ camlibs/ptp2/ptp-pack.c | 34 +++++++++++++++++++++++++---------
+ 1 file changed, 25 insertions(+), 9 deletions(-)
+
+diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c
+index 9eba06f..11428ab 100644
+--- a/camlibs/ptp2/ptp-pack.c
++++ b/camlibs/ptp2/ptp-pack.c
+@@ -1629,23 +1629,39 @@ ptp_pack_EOS_ImageFormat (PTPParams* params, unsigned char* data, uint16_t value
+ static inline char*
+ ptp_unpack_EOS_FocusInfoEx (PTPParams* params, const unsigned char** data, uint32_t datasize)
+ {
+- uint32_t size = dtoh32a( *data );
+- uint32_t halfsize = dtoh16a( (*data) + 4);
+- uint32_t version = dtoh16a( (*data) + 6);
+- uint32_t focus_points_in_struct = dtoh16a( (*data) + 8);
+- uint32_t focus_points_in_use = dtoh16a( (*data) + 10);
+- uint32_t sizeX = dtoh16a( (*data) + 12);
+- uint32_t sizeY = dtoh16a( (*data) + 14);
+- uint32_t size2X = dtoh16a( (*data) + 16);
+- uint32_t size2Y = dtoh16a( (*data) + 18);
++ uint32_t size;
++ uint32_t halfsize;
++ uint32_t version;
++ uint32_t focus_points_in_struct;
++ uint32_t focus_points_in_use;
++ uint32_t sizeX;
++ uint32_t sizeY;
++ uint32_t size2X;
++ uint32_t size2Y;
+ uint32_t i;
+ uint32_t maxlen;
+ char *str, *p;
+
++ if (datasize<4) {
++ ptp_error(params, "FocusInfoEx has invalid size (%d)", datasize);
++ return strdup("bad size 0");
++ }
++
++ size = dtoh32a( *data );
+ if ((size > datasize) || (size < 20)) {
+ ptp_error(params, "FocusInfoEx has invalid size (%d) vs datasize (%d)", size, datasize);
+ return strdup("bad size 1");
+ }
++
++ halfsize = dtoh16a( (*data) + 4);
++ version = dtoh16a( (*data) + 6);
++ focus_points_in_struct = dtoh16a( (*data) + 8);
++ focus_points_in_use = dtoh16a( (*data) + 10);
++ sizeX = dtoh16a( (*data) + 12);
++ sizeY = dtoh16a( (*data) + 14);
++ size2X = dtoh16a( (*data) + 16);
++ size2Y = dtoh16a( (*data) + 18);
++
+ /* If data is zero-filled, then it is just a placeholder, so nothing
+ useful, but also not an error */
+ if (!focus_points_in_struct || !focus_points_in_use) {
@@ -20,6 +20,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.xz;name=libgphoto2 \
file://CVE-2026-40338.patch \
file://CVE-2026-40339.patch \
file://CVE-2026-40340.patch \
+ file://CVE-2026-40341.patch \
"
SRC_URI[libgphoto2.sha256sum] = "28825f767a85544cb58f6e15028f8e53a5bb37a62148b3f1708b524781c3bef2"
Details: https://nvd.nist.gov/vuln/detail/CVE-2026-40341 Backport the patch referenced by the NVD advisory. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> --- .../gphoto2/libgphoto2/CVE-2026-40341.patch | 69 +++++++++++++++++++ .../gphoto2/libgphoto2_2.5.33.bb | 1 + 2 files changed, 70 insertions(+) create mode 100644 meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-40341.patch