diff --git a/meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-138158.patch b/meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-138158.patch
new file mode 100644
index 0000000000..8a01fae2b5
--- /dev/null
+++ b/meta-oe/recipes-graphics/gphoto2/libgphoto2/CVE-2026-138158.patch
@@ -0,0 +1,208 @@
+From 45bd74cec30a13a2343a572753fc0b020322bc21 Mon Sep 17 00:00:00 2001
+From: Marcus Meissner <marcus@jet.franken.de>
+Date: Sun, 8 Nov 2026 13:36:11 +0100
+Subject: [PATCH] sierra: Fixed stack bufferoverflow when using
+ sierra_get_string_register
+
+Basically the camera can report longer lengths than the what the string functions except
+and so overrun stack arrays.
+
+-fstack-protector could protect
+
+GHSA-4f44-frcc-8824
+
+Patch also by Deus Rex research team research@deusrex.ai
+Reported-by: Deus Rex research team research@deusrex.ai
+
+(cherry picked from commit c4cd525d7461c26b89b4705dc74fc4b84d57ff3a)
+
+CVE: CVE-2026-138158
+Upstream-Status: Backport [https://github.com/gphoto/libgphoto2/commit/c4cd525d7461c26b89b4705dc74fc4b84d57ff3a]
+Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
+---
+ camlibs/sierra/library.c     | 27 ++++++++++++++++++---------
+ camlibs/sierra/library.h     |  4 ++--
+ camlibs/sierra/sierra-desc.c |  2 +-
+ camlibs/sierra/sierra.c      | 17 +++++++++--------
+ 4 files changed, 30 insertions(+), 20 deletions(-)
+
+diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c
+index 30f939f02..5c2351062 100644
+--- a/camlibs/sierra/library.c
++++ b/camlibs/sierra/library.c
+@@ -157,7 +157,7 @@ int sierra_list_files (Camera *camera, const char *folder, CameraList *list, GPC
+ 	GP_DEBUG ("Getting filename of first file");
+ 	r = sierra_get_string_register (camera, 79, 1, NULL,
+ 					(unsigned char *)filename,
+-					&len, context);
++					sizeof(filename), &len, context);
+ 	if ((r < 0) || (len <= 0) || !strcmp (filename, "        ")) {
+ 		CHECK (gp_list_populate (list, "P101%04i.JPG", count));
+ 		return GP_OK;
+@@ -172,7 +172,7 @@ int sierra_list_files (Camera *camera, const char *folder, CameraList *list, GPC
+ 		GP_DEBUG ("Getting filename of file %i...", i + 1);
+ 		CHECK (sierra_get_string_register (camera, 79, i + 1, NULL,
+ 						   (unsigned char *)filename,
+-						   &len, context));
++						   sizeof(filename), &len, context));
+ 		if ((len <= 0) || !strcmp (filename, "        "))
+ 			snprintf (filename, sizeof (filename),
+ 				  "P101%04i.JPG", i + 1);
+@@ -205,7 +205,7 @@ int sierra_list_folders (Camera *camera, const char *folder, CameraList *list,
+ 		GP_DEBUG ("*** getting name of folder %i", i + 1);
+ 		CHECK (sierra_get_string_register (camera, 84, 0,
+ 						   NULL, (unsigned char *)buf,
+-						   &bsize, context));
++						   sizeof(buf), &bsize, context));
+ 
+ 		/* Remove trailing spaces */
+ 		for (j = strlen (buf) - 1; j >= 0 && buf[j] == ' '; j--)
+@@ -1204,7 +1204,8 @@ sierra_set_string_register (Camera *camera, int reg, const char *s,
+ 
+ int sierra_get_string_register (Camera *camera, int reg, int fnumber,
+ 				CameraFile *file, unsigned char *b,
+-				unsigned int *b_len, GPContext *context)
++				unsigned int b_size, unsigned int *b_len,
++				GPContext *context)
+ {
+ 	unsigned char p[34816];
+ 	unsigned int packlength, total = (b_len) ? *b_len : 0;
+@@ -1285,8 +1286,16 @@ int sierra_get_string_register (Camera *camera, int reg, int fnumber,
+ 		packlength = p[2] | (p[3] << 8);
+ 		GP_DEBUG ("Packet length: %d", packlength);
+ 
+-		if (b)
++		if (b) {
++			if (packlength > b_size - *b_len) {
++				GP_DEBUG ("Packet of %u bytes does not fit "
++					"(%u of %u used)", packlength,
++					*b_len, b_size);
++				in_function = 0;
++				return GP_ERROR_CORRUPTED_DATA;
++			}
+ 			memcpy (&b[*b_len], &p[4], packlength);
++		}
+ 		*b_len += packlength;
+ 
+ 		if (file) {
+@@ -1342,7 +1351,7 @@ sierra_capture_preview (Camera *camera, CameraFile *file, GPContext *context)
+ 
+ 	/* Retrieve the preview and set the MIME type */
+ 	CHECK (sierra_get_int_register (camera, 12, (int *)&size, context));
+-	CHECK (sierra_get_string_register (camera, 14, 0, file, NULL, &size,
++	CHECK (sierra_get_string_register (camera, 14, 0, file, NULL, 0, &size,
+ 					   context));
+ 	CHECK (gp_file_set_mime_type (file, GP_MIME_JPEG));
+ 
+@@ -1416,7 +1425,7 @@ sierra_capture (Camera *camera, CameraCaptureType type,
+ 		 */
+ 		CHECK (sierra_get_string_register (camera, 79, 0, NULL,
+ 						   (unsigned char *)filename,
+-						   &len, context));
++						   sizeof(filename), &len, context));
+ 		if ((len <= 0) || !strcmp (filename, "        "))
+ 			snprintf (filename, sizeof (filename), "P101%04i.JPG", n);
+ 		GP_DEBUG ("... done ('%s')", filename);
+@@ -1464,7 +1473,7 @@ int sierra_get_pic_info (Camera *camera, unsigned int n,
+ 	int value, audio_info[8];
+ 
+ 	CHECK (sierra_get_string_register (camera, 47, n, NULL, buf,
+-					   &buf_len, context));
++					   sizeof(buf), &buf_len, context));
+ 	if (buf_len == 0) {
+ 		/*
+ 		 * Many (older) serial cameras seem to return 0 bytes back
+@@ -1492,7 +1501,7 @@ int sierra_get_pic_info (Camera *camera, unsigned int n,
+ 		 */
+ 		if ((sierra_get_string_register (camera, 43, n, NULL,
+ 				(unsigned char *) &audio_info,
+-				(unsigned int *)&value,
++				sizeof(audio_info), (unsigned int *)&value,
+ 				context) == GP_OK) && (value != 0)) {
+ 			pic_info->size_audio = audio_info[0];
+ 		}
+diff --git a/camlibs/sierra/library.h b/camlibs/sierra/library.h
+index 20f7f36c9..ff88b9f85 100644
+--- a/camlibs/sierra/library.h
++++ b/camlibs/sierra/library.h
+@@ -122,8 +122,8 @@ int sierra_set_string_register	  (Camera *camera, int reg, const char *s,
+ 				   long int length, GPContext *context);
+ int sierra_get_string_register	  (Camera *camera, int reg, int file_number,
+ 				   CameraFile *file,
+-				   unsigned char *b, unsigned int *b_len,
+-				   GPContext *context);
++				   unsigned char *b, unsigned int b_size,
++				   unsigned int *b_len, GPContext *context);
+ int sierra_delete		  (Camera *camera, int picture_number,
+ 				   GPContext *context);
+ int sierra_delete_all             (Camera *camera, GPContext *context);
+diff --git a/camlibs/sierra/sierra-desc.c b/camlibs/sierra/sierra-desc.c
+index 56b66defc..4fec64ce1 100644
+--- a/camlibs/sierra/sierra-desc.c
++++ b/camlibs/sierra/sierra-desc.c
+@@ -126,7 +126,7 @@ camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p,
+ 		 * the fly and make a union with reg_value and a void*.
+ 		 */
+ 		ret = sierra_get_string_register (camera, reg_p->reg_number,
+-					  -1, NULL, (unsigned char *)buff, &value, context);
++					  -1, NULL, (unsigned char *)buff, sizeof(buff), &value, context);
+ 		if ((ret == GP_OK) && value != reg_p->reg_len) {
+ 			GP_DEBUG ("Bad length result %d", value);
+ 			return (GP_ERROR);
+diff --git a/camlibs/sierra/sierra.c b/camlibs/sierra/sierra.c
+index 867de9368..d3ef9e076 100644
+--- a/camlibs/sierra/sierra.c
++++ b/camlibs/sierra/sierra.c
+@@ -575,7 +575,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
+ 		break;
+ 	case GP_FILE_TYPE_AUDIO:
+ 		CHECK_STOP (camera, sierra_get_string_register (camera, 43, n, NULL,
+-			(unsigned char *) &audio_info, &transferred, context));
++			(unsigned char *) &audio_info, sizeof(audio_info),
++			&transferred, context));
+ 		if (transferred == 0)
+ 			download_size = 0;
+ 		else
+@@ -587,7 +588,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
+ 
+ 	/* Get the file */
+ 	CHECK_STOP (camera, sierra_get_string_register (camera, regd, n,
+-					file, NULL, (unsigned int *)&download_size,  context));
++					file, NULL, 0, (unsigned int *)&download_size,  context));
+ 	if (download_size == 0) {
+ 		/*
+ 		 * Assume a failure. At least coolpix 880 returns no error
+@@ -1955,19 +1956,19 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *c)
+ 	/* Get all the string-related info */
+ 
+ 	if (sierra_get_string_register (camera, 27, 0, NULL,
+-					(unsigned char *)t, (unsigned int *)&v, c) >= 0)
++					(unsigned char *)t, sizeof(t), (unsigned int *)&v, c) >= 0)
+ 		sprintf (buf+strlen(buf), _("Camera Model: %s\n"), t);
+ 	if (sierra_get_string_register (camera, 48, 0, NULL,
+-					(unsigned char *)t, (unsigned int *)&v, c) >= 0)
++					(unsigned char *)t, sizeof(t), (unsigned int *)&v, c) >= 0)
+ 		sprintf (buf+strlen(buf), _("Manufacturer: %s\n"), t);
+ 	if (sierra_get_string_register (camera, 22, 0, NULL,
+-					(unsigned char *)t, (unsigned int *)&v, c) >= 0)
++					(unsigned char *)t, sizeof(t), (unsigned int *)&v, c) >= 0)
+ 		sprintf (buf+strlen(buf), _("Camera ID: %s\n"), t);
+ 	if (sierra_get_string_register (camera, 25, 0, NULL,
+-					(unsigned char *)t, (unsigned int *)&v, c) >= 0)
++					(unsigned char *)t, sizeof(t), (unsigned int *)&v, c) >= 0)
+ 		sprintf (buf+strlen(buf), _("Serial Number: %s\n"), t);
+ 	if (sierra_get_string_register (camera, 26, 0, NULL,
+-					(unsigned char *)t, (unsigned int *)&v, c) >= 0)
++					(unsigned char *)t, sizeof(t), (unsigned int *)&v, c) >= 0)
+ 		sprintf (buf+strlen(buf), _("Software Rev.: %s\n"), t);
+ 
+ 	/* Get all the integer information */
+@@ -2025,7 +2026,7 @@ storage_info_func (CameraFilesystem *fs,
+ 	sif->fstype  = GP_STORAGEINFO_FST_DCF;
+ 
+ 	if (sierra_get_string_register (camera, 25, 0, NULL,
+-					(unsigned char *)t, (unsigned int *)&v, c) >= 0) {
++					(unsigned char *)t, sizeof(t), (unsigned int *)&v, c) >= 0) {
+ 		sif->fields |= GP_STORAGEINFO_LABEL;
+ 		strcpy (sif->label, t);
+ 	}
diff --git a/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.34.bb b/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.34.bb
index d8cf86ade2..0b8dacf8fa 100644
--- a/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.34.bb
+++ b/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.34.bb
@@ -14,6 +14,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.xz;name=libgphoto2 \
            file://0001-configure-Filter-out-buildpaths-from-CC.patch \
            file://CVE-2026-120451.patch \
            file://CVE-2026-120452.patch \
+           file://CVE-2026-138158.patch \
            "
 SRC_URI[libgphoto2.sha256sum] = "51993f5d9bfb6b4e5925cbbe5883085791bff6f81bcacb8ffe1b783ce76d586a"
 
