Skip to contentSkip to conversation

rrdtool: Fix do_configure by exporting ABS_TOP_BUILDDIR for perl bindings

PATCH In review Khem Raj 2 participants 4 messages Aug 5 – Aug 7

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 rrdtool: Fix do_configure by exporting ABS_TOP_BUILDDIR for perl bindings

1.10.3 grew a third branch in bindings/perl-shared/Makefile.PL: when ABS_TOP_BUILDDIR is unset it assumes a standalone build, pkg-config probes for an installed librrd and dies.

| pkg-config could not find librrd. Is rrdtool installed?
| Try: brew install rrdtool (macOS) or apt install librrd-dev (Debian/Ubuntu)

bindings/Makefile.am always passes ABS_TOP_SRCDIR, ABS_TOP_BUILDDIR and ABS_SRCDIR when it runs Makefile.PL, but do_configure re-runs it by hand to redo the perl bindings and did not. Export them there too so the in-tree branch is taken and RRDs links against -L${B}/src/.libs -lrrd.

Verified on aarch64 for qemuarm64: do_configure fails before the change with the error above, and do_compile and do_package succeed after.

---
 meta-oe/recipes-extended/rrdtool/rrdtool_1.10.3.bb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meta-oe/recipes-extended/rrdtool/rrdtool_1.10.3.bb +6 -1
index a434927b23..656cee7ffa 100644
@@ -97,9 +97,14 @@ do_configure() {
         ${B}/bindings/Makefile
 
     #redo the perl bindings
+    # perl-shared/Makefile.PL only links against the in-tree librrd when
+    # ABS_TOP_BUILDDIR is set, which is what bindings/Makefile.am does. Without
+    # it the standalone branch pkg-config probes for an installed librrd and
+    # dies with "pkg-config could not find librrd", so export them here too.
     (
     cd ${S}/bindings/perl-shared;
-    perl Makefile.PL INSTALLDIRS="vendor" INSTALLPRIVLIB="abc";
+    ABS_TOP_SRCDIR="${S}" ABS_TOP_BUILDDIR="${B}" ABS_SRCDIR="${S}/bindings/perl-shared" \
+        perl Makefile.PL INSTALLDIRS="vendor" INSTALLPRIVLIB="abc";
 
     cd ../../bindings/perl-piped;
     perl Makefile.PL INSTALLDIRS="vendor";
author
#1 lore raw

PATCH 2/3 net-snmp: Backport upstream fix for explicit library linking

libnetsnmptrapd uses symbols that live in libnetsnmpagent, but apps/Makefile.in only passes $(MIBLIB) and $(USELIBS) to the link. That works with GNU ld, which resolves symbols through the DT_NEEDED entries of the libraries named on the command line, and libnetsnmpmibs records a dependency on libnetsnmpagent. lld deliberately does not, so the link fails:

| ld.lld: error: undefined symbol: init_vacm_config_tokens
| >>> referenced by snmptrapd_auth.c:51
| >>>               .libs/snmptrapd_auth.o:(init_netsnmp_trapd_auth)
| ld.lld: error: undefined symbol: send_v2trap
| >>> referenced by snmptrapd_handlers.c:886
| >>>               .libs/snmptrapd_handlers.o:(axforward_handler)

Backport upstream commit 5e66246bd994 which names $(AGENTLIB) explicitly and additionally links libcrypto into libnetsnmpmibs and the apps, both of which rely on the same transitive resolution. The libnetsnmptrapd.la hunk is rebased because 5.9.5.2 still puts $(LDFLAGS) at the end of that link command.

Verified on aarch64 for qemuarm64: do_compile fails before the change with the errors above; after it do_compile and do_package succeed and libnetsnmptrapd.so records DT_NEEDED on libnetsnmpmibs, libnetsnmpagent and libnetsnmp directly.

---
 ...akefile.in-Link-libraries-explicitly.patch | 103 ++++++++++++++++++
 .../net-snmp/net-snmp_5.9.5.2.bb              |   1 +
 2 files changed, 104 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0012-apps-Makefile.in-Link-libraries-explicitly.patch
meta-networking/recipes-protocols/net-snmp/net-snmp/0012-apps-Makefile.in-Link-libraries-explicitly.patch new file +103 -0
new file mode 100644
index 0000000000..5129282ef2
@@ -0,0 +1,103 @@
+From 5e66246bd994a2f693bd02773823691c8d07a070 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <[email protected]>
+Date: Fri, 24 Jul 2026 09:34:18 -0700
+Subject: [PATCH] apps/Makefile.in: Link libraries explicitly
+
+When building Net-SNMP with -no-undefined (which is used for libraries like
+libnetsnmpmibs.la and libnetsnmptrapd.la) and link_all_deplibs=no (default on
+modern systems to prevent overlinking), compilation fails due to undefined
+references to symbols from transitive dependencies.
+
+1. libnetsnmpmibs.la fails to link because it uses OpenSSL DH/BN symbols
+   (when snmp-usm-dh-objects-mib is enabled) but does not link with
+   libcrypto directly. Fix this by adding LIBCRYPTO to LMIBLIBS in
+   configure if OpenSSL is used, and exporting LIBCRYPTO.
+
+2. libnetsnmptrapd.la fails to link because it uses symbols from
+   libnetsnmpagent.la (like vacm_check_view_contents) but does not link with
+   it directly. Fix this by adding $(AGENTLIB) to libnetsnmptrapd.la link
+   line in apps/Makefile.in.
+
+3. Executables in apps/ (like snmpusm and snmptls) fail to link because
+   they use OpenSSL symbols directly but do not link with libcrypto/libssl
+   directly. Fix this by adding @LIBCRYPTO@ to LIBS in apps/Makefile.in.
+
+This makes Net-SNMP compatible with newer versions of libtool.
+
+Upstream-Status: Backport [https://github.com/net-snmp/net-snmp/commit/5e66246bd994a2f693bd02773823691c8d07a070]
+
+The libnetsnmptrapd.la hunk is rebased: 5.9.5.2 still puts $(LDFLAGS) at
+the end of that link command, upstream has since moved it before
+$(LLIBTRAPD_OBJS). The change itself is unmodified.
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ apps/Makefile.in            | 4 ++--
+ configure                   | 7 +++++++
+ configure.d/config_os_libs2 | 6 ++++++
+ 3 files changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/apps/Makefile.in b/apps/Makefile.in
+index 57b8524..252fd84 100644
+--- a/apps/Makefile.in
++++ b/apps/Makefile.in
+@@ -95,7 +95,7 @@ MYSQL_LIBS	= @MYSQL_LIBS@
+ MYSQL_INCLUDES	= @MYSQL_INCLUDES@
+
+ VAL_LIBS	= @VAL_LIBS@
+-LIBS		= $(USELIBS) $(VAL_LIBS) @LIBS@
++LIBS		= $(USELIBS) $(VAL_LIBS) @LIBS@ @LIBCRYPTO@
+ PERLLDOPTS_FOR_APPS = @PERLLDOPTS_FOR_APPS@
+ PERLLDOPTS_FOR_LIBS = @PERLLDOPTS_FOR_LIBS@
+
+@@ -235,7 +235,7 @@ snmppcap$(EXEEXT):    snmppcap.$(OSUFFIX) $(USEAGENTLIBS)
+ 	$(LINK) ${CFLAGS} -o $@ snmppcap.$(OSUFFIX) ${LDFLAGS} ${USEAGENTLIBS} ${LIBS} -lpcap
+
+ libnetsnmptrapd.$(LIB_EXTENSION)$(LIB_VERSION): $(LLIBTRAPD_OBJS)
+-	$(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(MYSQL_LIBS) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LDFLAGS)
++	$(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(AGENTLIB) $(MYSQL_LIBS) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LDFLAGS)
+ 	$(RANLIB) $@
+
+ snmpinforminstall:
+diff --git a/configure b/configure
+index 6ef0026..4270aff 100755
+--- a/configure
++++ b/configure
+@@ -683,6 +683,7 @@ PERLLDOPTS_FOR_APPS
+ PERLLDOPTS_FOR_LIBS
+ EMBEDPERLUNINSTALL
+ EMBEDPERLINSTALL
++LIBCRYPTO
+ LIBCURSES
+ HAVE_LIBCURSES
+ NETSNMP_BUILD_PCAP_PROG_FALSE
+@@ -32065,6 +32066,12 @@ printf "%s\n" "$netsnmp_cv_func_ceil_LNETSNMPLIBS" >&6; }
+  fi
+
+
++if test x$CRYPTO != x; then
++    LMIBLIBS="$LMIBLIBS $LIBCRYPTO"
++fi
++
++
++
+ cat >confcache <<\_ACEOF
+ # This file is a shell script that caches the results of configure
+ # tests run on this system so they can be shared between configure
+diff --git a/configure.d/config_os_libs2 b/configure.d/config_os_libs2
+index 5787e58..d21ea77 100644
+--- a/configure.d/config_os_libs2
++++ b/configure.d/config_os_libs2
+@@ -718,3 +718,9 @@ AC_SUBST([LIBCURSES])
+ #   libm for ceil
+ #
+ NETSNMP_SEARCH_LIBS(ceil, m,,,, LNETSNMPLIBS)
++
++if test x$CRYPTO != x; then
++    LMIBLIBS="$LMIBLIBS $LIBCRYPTO"
++fi
++
++AC_SUBST(LIBCRYPTO)
+--
+2.43.0
+
meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.5.2.bb +1 -0
index 00a7b50cdf..48704d020f 100644
@@ -24,6 +24,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
            file://0009-net-snmp-fix-for-disable-des.patch \
            file://0010-net-snmp-Reproducibility-Don-t-check-build-host-for.patch \
            file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
+           file://0012-apps-Makefile.in-Link-libraries-explicitly.patch \
            file://netsnmp-swinst-crash.patch \
            "
 SRC_URI[sha256sum] = "16707719f833184a4b72835dac359ae188123b06b5e42817c00790d7dc1384bf"
Tested-by on v1 2/3
#2 lore raw

Re: [oe] [meta-networking][PATCH 2/3] net-snmp: Backport upstream fix for explicit library linking

Hi Khem,

This fixes the net-snmp 5.9.5.2 do_compile failure we hit after the libtool 2.5.4 → 2.6.2 upgrade (link_all_deplibs=no exposing missing direct dependencies in libnetsnmptrapd).

Regards,
Jaipaul
From: [email protected] <[email protected]> on behalf of Khem Raj via lists.openembedded.org <[email protected]>
Date: Wednesday, 5 August 2026 at 23:26
To: [email protected] <[email protected]>
Cc: Khem Raj <[email protected]>
Subject: [oe] [meta-networking][PATCH 2/3] net-snmp: Backport upstream fix for explicit library linking

libnetsnmptrapd uses symbols that live in libnetsnmpagent, but apps/Makefile.in only passes $(MIBLIB) and $(USELIBS) to the link. That works with GNU ld, which resolves symbols through the DT_NEEDED entries of the libraries named on the command line, and libnetsnmpmibs records a dependency on libnetsnmpagent. lld deliberately does not, so the link fails:

| ld.lld: error: undefined symbol: init_vacm_config_tokens
| >>> referenced by snmptrapd_auth.c:51
| >>>               .libs/snmptrapd_auth.o:(init_netsnmp_trapd_auth)
| ld.lld: error: undefined symbol: send_v2trap
| >>> referenced by snmptrapd_handlers.c:886
| >>>               .libs/snmptrapd_handlers.o:(axforward_handler)

Backport upstream commit 5e66246bd994 which names $(AGENTLIB) explicitly and additionally links libcrypto into libnetsnmpmibs and the apps, both of which rely on the same transitive resolution. The libnetsnmptrapd.la hunk is rebased because 5.9.5.2 still puts $(LDFLAGS) at the end of that link command.

Verified on aarch64 for qemuarm64: do_compile fails before the change with the errors above; after it do_compile and do_package succeed and libnetsnmptrapd.so records DT_NEEDED on libnetsnmpmibs, libnetsnmpagent and libnetsnmp directly.

---
 ...akefile.in-Link-libraries-explicitly.patch | 103 ++++++++++++++++++
 .../net-snmp/net-snmp_5.9.5.2.bb              |   1 +
 2 files changed, 104 insertions(+)
 create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0012-apps-Makefile.in-Link-libraries-explicitly.patch
meta-networking/recipes-protocols/net-snmp/net-snmp/0012-apps-Makefile.in-Link-libraries-explicitly.patch new file +103 -0
new file mode 100644
index 0000000000..5129282ef2
@@ -0,0 +1,103 @@
+From 5e66246bd994a2f693bd02773823691c8d07a070 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <[email protected]>
+Date: Fri, 24 Jul 2026 09:34:18 -0700
+Subject: [PATCH] apps/Makefile.in: Link libraries explicitly
+
+When building Net-SNMP with -no-undefined (which is used for libraries like
+libnetsnmpmibs.la and libnetsnmptrapd.la) and link_all_deplibs=no (default on
+modern systems to prevent overlinking), compilation fails due to undefined
+references to symbols from transitive dependencies.
+
+1. libnetsnmpmibs.la fails to link because it uses OpenSSL DH/BN symbols
+   (when snmp-usm-dh-objects-mib is enabled) but does not link with
+   libcrypto directly. Fix this by adding LIBCRYPTO to LMIBLIBS in
+   configure if OpenSSL is used, and exporting LIBCRYPTO.
+
+2. libnetsnmptrapd.la fails to link because it uses symbols from
+   libnetsnmpagent.la (like vacm_check_view_contents) but does not link with
+   it directly. Fix this by adding $(AGENTLIB) to libnetsnmptrapd.la link
+   line in apps/Makefile.in.
+
+3. Executables in apps/ (like snmpusm and snmptls) fail to link because
+   they use OpenSSL symbols directly but do not link with libcrypto/libssl
+   directly. Fix this by adding @LIBCRYPTO@ to LIBS in apps/Makefile.in.
+
+This makes Net-SNMP compatible with newer versions of libtool.
+
+Upstream-Status: Backport [https://github.com/net-snmp/net-snmp/commit/5e66246bd994a2f693bd02773823691c8d07a070]
+
+The libnetsnmptrapd.la hunk is rebased: 5.9.5.2 still puts $(LDFLAGS) at
+the end of that link command, upstream has since moved it before
+$(LLIBTRAPD_OBJS). The change itself is unmodified.
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ apps/Makefile.in            | 4 ++--
+ configure                   | 7 +++++++
+ configure.d/config_os_libs2 | 6 ++++++
+ 3 files changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/apps/Makefile.in b/apps/Makefile.in
+index 57b8524..252fd84 100644
+--- a/apps/Makefile.in
++++ b/apps/Makefile.in
+@@ -95,7 +95,7 @@ MYSQL_LIBS   = @MYSQL_LIBS@
+ MYSQL_INCLUDES        = @MYSQL_INCLUDES@
+
+ VAL_LIBS      = @VAL_LIBS@
+-LIBS          = $(USELIBS) $(VAL_LIBS) @LIBS@
++LIBS          = $(USELIBS) $(VAL_LIBS) @LIBS@ @LIBCRYPTO@
+ PERLLDOPTS_FOR_APPS = @PERLLDOPTS_FOR_APPS@
+ PERLLDOPTS_FOR_LIBS = @PERLLDOPTS_FOR_LIBS@
+
+@@ -235,7 +235,7 @@ snmppcap$(EXEEXT):    snmppcap.$(OSUFFIX) $(USEAGENTLIBS)
+        $(LINK) ${CFLAGS} -o $@ snmppcap.$(OSUFFIX) ${LDFLAGS} ${USEAGENTLIBS} ${LIBS} -lpcap
+
+ libnetsnmptrapd.$(LIB_EXTENSION)$(LIB_VERSION): $(LLIBTRAPD_OBJS)
+-      $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(MYSQL_LIBS) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LDFLAGS)
++      $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(AGENTLIB) $(MYSQL_LIBS) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LDFLAGS)
+        $(RANLIB) $@
+
+ snmpinforminstall:
+diff --git a/configure b/configure
+index 6ef0026..4270aff 100755
+--- a/configure
++++ b/configure
+@@ -683,6 +683,7 @@ PERLLDOPTS_FOR_APPS
+ PERLLDOPTS_FOR_LIBS
+ EMBEDPERLUNINSTALL
+ EMBEDPERLINSTALL
++LIBCRYPTO
+ LIBCURSES
+ HAVE_LIBCURSES
+ NETSNMP_BUILD_PCAP_PROG_FALSE
+@@ -32065,6 +32066,12 @@ printf "%s\n" "$netsnmp_cv_func_ceil_LNETSNMPLIBS" >&6; }
+  fi
+
+
++if test x$CRYPTO != x; then
++    LMIBLIBS="$LMIBLIBS $LIBCRYPTO"
++fi
++
++
++
+ cat >confcache <<\_ACEOF
+ # This file is a shell script that caches the results of configure
+ # tests run on this system so they can be shared between configure
+diff --git a/configure.d/config_os_libs2 b/configure.d/config_os_libs2
+index 5787e58..d21ea77 100644
+--- a/configure.d/config_os_libs2
++++ b/configure.d/config_os_libs2
+@@ -718,3 +718,9 @@ AC_SUBST([LIBCURSES])
+ #   libm for ceil
+ #
+ NETSNMP_SEARCH_LIBS(ceil, m,,,, LNETSNMPLIBS)
++
++if test x$CRYPTO != x; then
++    LMIBLIBS="$LMIBLIBS $LIBCRYPTO"
++fi
++
++AC_SUBST(LIBCRYPTO)
+--
+2.43.0
+
meta-networking/recipes-protocols/net-snmp/net-snmp_5.9.5.2.bb +1 -0
index 00a7b50cdf..48704d020f 100644
@@ -24,6 +24,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \
            file://0009-net-snmp-fix-for-disable-des.patch \
            file://0010-net-snmp-Reproducibility-Don-t-check-build-host-for.patch \
            file://0011-ac_add_search_path.m4-keep-consistent-between-32bit-.patch \
+           file://0012-apps-Makefile.in-Link-libraries-explicitly.patch \
            file://netsnmp-swinst-crash.patch \
            "
 SRC_URI[sha256sum] = "16707719f833184a4b72835dac359ae188123b06b5e42817c00790d7dc1384bf"
author
#3 lore raw

PATCH 3/3 cjose: Fix build with clang by initializing decoded buffer lengths

In reply to Khem Raj

_cjose_jwk_import_RSA() and _cjose_jwk_import_EC() declare their *_buflen variables in the middle of the function, interleaved with error paths that goto a shared cleanup label. An early decode failure jumps over the remaining declarations, and the cleanup block then reads them uninitialized:

| jwk.c:1501:9: error: variable 'dq_buflen' is used uninitialized
|                whenever 'if' condition is true
|                [-Werror,-Wsometimes-uninitialized]
| jwk.c:1554:39: note: uninitialized use occurs here
|     _cjose_cleanse_dealloc(dq_buffer, dq_buflen);

_cjose_cleanse_dealloc() uses the length to wipe key material, so this is an out-of-bounds write hazard on the error path rather than just a warning. src/Makefile.am builds with -Werror, so clang also makes it fatal; the 0.6.2.4 -> 0.6.2.7 upgrade exposed it.

Verified on aarch64 for qemuarm64: do_compile fails before the change with 20 such errors, and do_compile and do_package succeed after.

---
 ...-the-decoded-buffer-lengths-up-front.patch | 149 ++++++++++++++++++
 .../recipes-support/cjose/cjose_0.6.2.7.bb    |   4 +-
 2 files changed, 152 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/cjose/cjose/0001-jwk-initialize-the-decoded-buffer-lengths-up-front.patch
meta-oe/recipes-support/cjose/cjose/0001-jwk-initialize-the-decoded-buffer-lengths-up-front.patch new file +149 -0
new file mode 100644
index 0000000000..eace7b659f
@@ -0,0 +1,149 @@
+From 5e8337d3c0ad2b19b78098f72814fbe2442226c9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 5 Aug 2026 19:27:04 +0000
+Subject: [PATCH] jwk: initialize the decoded buffer lengths up front
+
+_cjose_jwk_import_EC() and _cjose_jwk_import_RSA() declare their
+*_buflen variables in the middle of the function, interleaved with
+error paths that goto the shared cleanup label. When an early decode
+fails, the goto jumps over the remaining declarations and the cleanup
+block then reads them uninitialized:
+
+| jwk.c:1501:9: error: variable 'dq_buflen' is used uninitialized
+|                whenever 'if' condition is true
+|                [-Werror,-Wsometimes-uninitialized]
+| jwk.c:1554:39: note: uninitialized use occurs here
+|     _cjose_cleanse_dealloc(dq_buffer, dq_buflen);
+
+_cjose_cleanse_dealloc() uses the length to wipe key material, so this
+is a real out-of-bounds write hazard on the error path, not just a
+warning. src/Makefile.am builds with -Werror, so it also breaks the
+build with clang.
+
+Declare the lengths alongside the buffers they pair with and assign
+them where they were previously initialized.
+
+Upstream-Status: Submitted [https://github.com/OpenIDC/cjose/pull/32]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/jwk.c | 25 ++++++++++++++-----------
+ 1 file changed, 14 insertions(+), 11 deletions(-)
+
+diff --git a/src/jwk.c b/src/jwk.c
+index 9c57a0b..58f872b 100644
+--- a/src/jwk.c
++++ b/src/jwk.c
+@@ -1371,6 +1371,9 @@ static cjose_jwk_t *_cjose_jwk_import_EC(json_t *jwk_json, cjose_err *err)
+     uint8_t *x_buffer = NULL;
+     uint8_t *y_buffer = NULL;
+     uint8_t *d_buffer = NULL;
++    size_t x_buflen = 0;
++    size_t y_buflen = 0;
++    size_t d_buflen = 0;
+
+     // get the value of the crv attribute
+     const char *crv_str = _get_json_object_string_attribute(jwk_json, CJOSE_JWK_CRV_STR, err);
+@@ -1389,7 +1392,7 @@ static cjose_jwk_t *_cjose_jwk_import_EC(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of the x coordinate
+-    size_t x_buflen = (size_t)_ec_size_for_curve(crv, err);
++    x_buflen = (size_t)_ec_size_for_curve(crv, err);
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_X_STR, &x_buffer, &x_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1397,7 +1400,7 @@ static cjose_jwk_t *_cjose_jwk_import_EC(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of the y coordinate
+-    size_t y_buflen = (size_t)_ec_size_for_curve(crv, err);
++    y_buflen = (size_t)_ec_size_for_curve(crv, err);
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_Y_STR, &y_buffer, &y_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1405,7 +1408,7 @@ static cjose_jwk_t *_cjose_jwk_import_EC(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of the private key d
+-    size_t d_buflen = (size_t)_ec_size_for_curve(crv, err);
++    d_buflen = (size_t)_ec_size_for_curve(crv, err);
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_D_STR, &d_buffer, &d_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1455,9 +1458,16 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     uint8_t *dp_buffer = NULL;
+     uint8_t *dq_buffer = NULL;
+     uint8_t *qi_buffer = NULL;
++    size_t n_buflen = 0;
++    size_t e_buflen = 0;
++    size_t d_buflen = 0;
++    size_t p_buflen = 0;
++    size_t q_buflen = 0;
++    size_t dp_buflen = 0;
++    size_t dq_buflen = 0;
++    size_t qi_buflen = 0;
+
+     // get the decoded value of n (buflen = 0 means no particular expected len)
+-    size_t n_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_N_STR, &n_buffer, &n_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1465,7 +1475,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of e
+-    size_t e_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_E_STR, &e_buffer, &e_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1473,7 +1482,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of d
+-    size_t d_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_D_STR, &d_buffer, &d_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1481,7 +1489,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of p
+-    size_t p_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_P_STR, &p_buffer, &p_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1489,7 +1496,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of q
+-    size_t q_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_Q_STR, &q_buffer, &q_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1497,7 +1503,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of dp
+-    size_t dp_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_DP_STR, &dp_buffer, &dp_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1505,7 +1510,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of dq
+-    size_t dq_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_DQ_STR, &dq_buffer, &dq_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+@@ -1513,7 +1517,6 @@ static cjose_jwk_t *_cjose_jwk_import_RSA(json_t *jwk_json, cjose_err *err)
+     }
+
+     // get the decoded value of qi
+-    size_t qi_buflen = 0;
+     if (!_decode_json_object_base64url_attribute(jwk_json, CJOSE_JWK_QI_STR, &qi_buffer, &qi_buflen, err))
+     {
+         CJOSE_ERROR(err, CJOSE_ERR_INVALID_ARG);
+--
+2.43.0
+
meta-oe/recipes-support/cjose/cjose_0.6.2.7.bb +3 -1
index b35cf349f1..4538d33ef6 100644
@@ -3,7 +3,9 @@ HOMEPAGE = "https://github.com/OpenIDC/cjose"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=7249e2f9437adfb8c88d870438042f0e"
 
-SRC_URI = "git://github.com/OpenIDC/cjose;protocol=https;branch=version-0.6.2.x;tag=v${PV}"
+SRC_URI = "git://github.com/OpenIDC/cjose;protocol=https;branch=version-0.6.2.x;tag=v${PV} \
+           file://0001-jwk-initialize-the-decoded-buffer-lengths-up-front.patch \
+           "
 
 SRCREV = "10af8915a666b50caa5500cdc3f2523b916be720"