diff options
| author | Gyorgy Sarvari <skandigraun@gmail.com> | 2026-04-20 08:27:41 +0200 |
|---|---|---|
| committer | Anuj Mittal <anuj.mittal@oss.qualcomm.com> | 2026-04-24 21:13:20 +0530 |
| commit | 9e9977200d2f52f326f0ba18e1743b8a1490e140 (patch) | |
| tree | c071e10d1839372314573960abe5f06711dc5736 /meta-oe | |
| parent | ba9800188ef40c67e044cf8ca53573d894a96310 (diff) | |
| download | meta-openembedded-9e9977200d2f52f326f0ba18e1743b8a1490e140.tar.gz | |
libgphoto2: patch CVE-2026-40333
Details: https://nvd.nist.gov/vuln/detail/CVE-2026-40333
Backport the patch referenced by the NVD advisory.
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
(cherry picked from commit 754e02c668a1130e3808cdaa4dbd5c7954e99890)
Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
Diffstat (limited to 'meta-oe')
| -rw-r--r-- | meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-40333.patch | 150 | ||||
| -rw-r--r-- | meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb | 3 |
2 files changed, 152 insertions, 1 deletions
diff --git a/meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-40333.patch b/meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-40333.patch new file mode 100644 index 0000000000..77c307e88d --- /dev/null +++ b/meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-40333.patch | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | From 8fefd2da7b9e2c7c448086cd251b108c0ebf1262 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Marcus Meissner <marcus@jet.franken.de> | ||
| 3 | Date: Wed, 8 Apr 2026 15:18:42 +0200 | ||
| 4 | Subject: [PATCH] Fixed EOS ImageFormat/CustomFuncEx Parsers Lack Length | ||
| 5 | Parameter | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | ptp_unpack_EOS_ImageFormat() and ptp_unpack_EOS_CustomFuncEx() accept | ||
| 11 | const unsigned char** data but no length/size parameter. They perform | ||
| 12 | unbounded reads via dtoh32o calls (up to 36 bytes for ImageFormat, | ||
| 13 | up to 1024 bytes for CustomFuncEx). Callers in ptp_unpack_EOS_events() | ||
| 14 | have xsize available but never pass it. | ||
| 15 | |||
| 16 | CVE-2026-40333 | ||
| 17 | |||
| 18 | Reported-By: Sebastián Alba <sebasjosue84@gmail.com> | ||
| 19 | |||
| 20 | CVE: CVE-2026-40333 | ||
| 21 | Upstream-Status: Backport [https://github.com/gphoto/libgphoto2/commit/1817ecead20c2aafa7549dac9619fe38f47b2f53] | ||
| 22 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
| 23 | --- | ||
| 24 | camlibs/ptp2/ptp-pack.c | 53 ++++++++++++++++++++++++++++++++++------- | ||
| 25 | 1 file changed, 44 insertions(+), 9 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c | ||
| 28 | index 09421b7..09dcc24 100644 | ||
| 29 | --- a/camlibs/ptp2/ptp-pack.c | ||
| 30 | +++ b/camlibs/ptp2/ptp-pack.c | ||
| 31 | @@ -1448,7 +1448,7 @@ ptp_unpack_Canon_EOS_FE (PTPParams *params, const unsigned char* data, unsigned | ||
| 32 | |||
| 33 | |||
| 34 | static inline uint16_t | ||
| 35 | -ptp_unpack_EOS_ImageFormat (PTPParams* params, const unsigned char** data ) | ||
| 36 | +ptp_unpack_EOS_ImageFormat (PTPParams* params, const unsigned char** data, unsigned int *size ) | ||
| 37 | { | ||
| 38 | /* | ||
| 39 | EOS ImageFormat entries look are a sequence of u32 values: | ||
| 40 | @@ -1492,30 +1492,57 @@ ptp_unpack_EOS_ImageFormat (PTPParams* params, const unsigned char** data ) | ||
| 41 | |||
| 42 | const uint8_t* d = *data; | ||
| 43 | uint32_t offset = 0; | ||
| 44 | - uint32_t n = dtoh32o (d, offset); | ||
| 45 | + uint32_t n; | ||
| 46 | uint32_t l, t1, s1, c1, t2 = 0, s2 = 0, c2 = 0; | ||
| 47 | |||
| 48 | + if (*size < sizeof(uint32_t)) { | ||
| 49 | + ptp_debug (params, "parsing EOS ImageFormat property failed 1 (size %d)", *size); | ||
| 50 | + return 0; | ||
| 51 | + } | ||
| 52 | + n = dtoh32o (d, offset); | ||
| 53 | + *size -= sizeof(uint32_t); | ||
| 54 | + | ||
| 55 | if (n != 1 && n !=2) { | ||
| 56 | ptp_debug (params, "parsing EOS ImageFormat property failed (n != 1 && n != 2: %d)", n); | ||
| 57 | return 0; | ||
| 58 | } | ||
| 59 | - | ||
| 60 | + if (*size < sizeof(uint32_t)) { | ||
| 61 | + ptp_debug (params, "parsing EOS ImageFormat property failed 2 (size %d)", *size); | ||
| 62 | + return 0; | ||
| 63 | + } | ||
| 64 | l = dtoh32o (d, offset); | ||
| 65 | + *size -= sizeof(uint32_t); | ||
| 66 | + | ||
| 67 | if (l != 0x10) { | ||
| 68 | ptp_debug (params, "parsing EOS ImageFormat property failed (l != 0x10: 0x%x)", l); | ||
| 69 | return 0; | ||
| 70 | } | ||
| 71 | |||
| 72 | + if (*size < 3*sizeof(uint32_t)) { | ||
| 73 | + ptp_debug (params, "parsing EOS ImageFormat property failed 3 (size %d)", *size); | ||
| 74 | + return 0; | ||
| 75 | + } | ||
| 76 | t1 = dtoh32o (d, offset); | ||
| 77 | s1 = dtoh32o (d, offset); | ||
| 78 | c1 = dtoh32o (d, offset); | ||
| 79 | + *size -= 3*sizeof(uint32_t); | ||
| 80 | |||
| 81 | if (n == 2) { | ||
| 82 | + if (*size < sizeof(uint32_t)) { | ||
| 83 | + ptp_debug (params, "parsing EOS ImageFormat property failed 4 (size %d)", *size); | ||
| 84 | + return 0; | ||
| 85 | + } | ||
| 86 | l = dtoh32o (d, offset); | ||
| 87 | + *size -= sizeof(uint32_t); | ||
| 88 | + | ||
| 89 | if (l != 0x10) { | ||
| 90 | ptp_debug (params, "parsing EOS ImageFormat property failed (l != 0x10: 0x%x)", l); | ||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | + if (*size < 3*sizeof(uint32_t)) { | ||
| 94 | + ptp_debug (params, "parsing EOS ImageFormat property failed 5 (size %d)", *size); | ||
| 95 | + return 0; | ||
| 96 | + } | ||
| 97 | t2 = dtoh32o (d, offset); | ||
| 98 | s2 = dtoh32o (d, offset); | ||
| 99 | c2 = dtoh32o (d, offset); | ||
| 100 | @@ -1668,12 +1695,20 @@ ptp_unpack_EOS_FocusInfoEx (PTPParams* params, const unsigned char** data, uint3 | ||
| 101 | |||
| 102 | |||
| 103 | static inline char* | ||
| 104 | -ptp_unpack_EOS_CustomFuncEx (PTPParams* params, const unsigned char** data ) | ||
| 105 | +ptp_unpack_EOS_CustomFuncEx (PTPParams* params, const unsigned char** data, unsigned int *size ) | ||
| 106 | { | ||
| 107 | - uint32_t s = dtoh32a( *data ); | ||
| 108 | - uint32_t n = s/4, i; | ||
| 109 | + uint32_t s, n, i; | ||
| 110 | char *str, *p; | ||
| 111 | |||
| 112 | + if (*size < sizeof(uint32_t)) | ||
| 113 | + return strdup("bad length"); | ||
| 114 | + | ||
| 115 | + s = dtoh32a( *data ); | ||
| 116 | + n = s/4; | ||
| 117 | + | ||
| 118 | + if (*size < 4+s) | ||
| 119 | + return strdup("bad length"); | ||
| 120 | + | ||
| 121 | if (s > 1024) { | ||
| 122 | ptp_debug (params, "customfuncex data is larger than 1k / %d... unexpected?", s); | ||
| 123 | return strdup("bad length"); | ||
| 124 | @@ -1962,7 +1997,7 @@ ptp_unpack_EOS_events (PTPParams *params, const unsigned char* data, unsigned in | ||
| 125 | case PTP_DPC_CANON_EOS_ImageFormatExtHD: | ||
| 126 | /* special handling of ImageFormat properties */ | ||
| 127 | for (j=0;j<dpd_count;j++) { | ||
| 128 | - dpd->FORM.Enum.SupportedValue[j].u16 = ptp_unpack_EOS_ImageFormat( params, &xdata ); | ||
| 129 | + dpd->FORM.Enum.SupportedValue[j].u16 = ptp_unpack_EOS_ImageFormat( params, &xdata, &xsize ); | ||
| 130 | ptp_debug (params, INDENT "prop %x option[%2d] == 0x%04x", dpc, j, dpd->FORM.Enum.SupportedValue[j].u16); | ||
| 131 | } | ||
| 132 | break; | ||
| 133 | @@ -2267,7 +2302,7 @@ ptp_unpack_EOS_events (PTPParams *params, const unsigned char* data, unsigned in | ||
| 134 | case PTP_DPC_CANON_EOS_ImageFormatSD: | ||
| 135 | case PTP_DPC_CANON_EOS_ImageFormatExtHD: | ||
| 136 | dpd->DataType = PTP_DTC_UINT16; | ||
| 137 | - dpd->DefaultValue.u16 = ptp_unpack_EOS_ImageFormat( params, &xdata ); | ||
| 138 | + dpd->DefaultValue.u16 = ptp_unpack_EOS_ImageFormat( params, &xdata, &xsize ); | ||
| 139 | dpd->CurrentValue.u16 = dpd->DefaultValue.u16; | ||
| 140 | ptp_debug (params, INDENT "prop %x value == 0x%04x (u16)", dpc, dpd->CurrentValue.u16); | ||
| 141 | break; | ||
| 142 | @@ -2275,7 +2310,7 @@ ptp_unpack_EOS_events (PTPParams *params, const unsigned char* data, unsigned in | ||
| 143 | dpd->DataType = PTP_DTC_STR; | ||
| 144 | free (dpd->DefaultValue.str); | ||
| 145 | free (dpd->CurrentValue.str); | ||
| 146 | - dpd->DefaultValue.str = ptp_unpack_EOS_CustomFuncEx( params, &xdata ); | ||
| 147 | + dpd->DefaultValue.str = ptp_unpack_EOS_CustomFuncEx( params, &xdata, &xsize ); | ||
| 148 | dpd->CurrentValue.str = strdup( (char*)dpd->DefaultValue.str ); | ||
| 149 | ptp_debug (params, INDENT "prop %x value == %s", dpc, dpd->CurrentValue.str); | ||
| 150 | break; | ||
diff --git a/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb b/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb index 6b5e6c21b9..e5a64c504a 100644 --- a/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb +++ b/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb | |||
| @@ -12,7 +12,8 @@ DEPENDS = "libtool jpeg virtual/libusb0 libexif zlib libxml2" | |||
| 12 | SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.xz;name=libgphoto2 \ | 12 | SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.xz;name=libgphoto2 \ |
| 13 | file://40-libgphoto2.rules \ | 13 | file://40-libgphoto2.rules \ |
| 14 | file://0001-configure-Filter-out-buildpaths-from-CC.patch \ | 14 | file://0001-configure-Filter-out-buildpaths-from-CC.patch \ |
| 15 | " | 15 | file://CVE-2026-40333.patch \ |
| 16 | " | ||
| 16 | SRC_URI[libgphoto2.sha256sum] = "28825f767a85544cb58f6e15028f8e53a5bb37a62148b3f1708b524781c3bef2" | 17 | SRC_URI[libgphoto2.sha256sum] = "28825f767a85544cb58f6e15028f8e53a5bb37a62148b3f1708b524781c3bef2" |
| 17 | 18 | ||
| 18 | UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/gphoto/files/libgphoto/" | 19 | UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/gphoto/files/libgphoto/" |
