kumquat-buildroot/package/pkcs11-helper/0002-openssl-libressl-3-5-0-does-not-have-DSA_meth_set1_name.patch
Fabrice Fontaine 1195486b58 package/pkcs11-helper: fix build with libressl >= 3.5.0
Fix the following build failure with libressl raised since bump to
version 3.5.2 in commit 8b216927db:

pkcs11h-openssl.c: In function 'DSA_meth_set1_name':
pkcs11h-openssl.c:239:41: error: invalid use of incomplete typedef 'DSA_METHOD' {aka 'struct dsa_method'}
  239 |  rv = _pkcs11h_mem_strdup ((void *)&meth->name, name);
      |                                         ^~

Fixes:
 - http://autobuild.buildroot.org/results/9b0d3bf7d97696c7be6de1724daaba196626b865

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2022-05-13 23:54:11 +02:00

70 lines
1.9 KiB
Diff

From 17d10b0dfb2b56a047db307687640adcd560e199 Mon Sep 17 00:00:00 2001
From: Alon Bar-Lev <alon.barlev@gmail.com>
Date: Mon, 2 May 2022 21:26:58 +0300
Subject: [PATCH] openssl: libressl-3.5.0 does not have DSA_meth_set1_name
while it does not expose the DSA_METHOD structure.
[Retrieved (and updated to remove ChangeLog update) from:
https://github.com/OpenSC/pkcs11-helper/commit/17d10b0dfb2b56a047db307687640adcd560e199]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
ChangeLog | 1 +
configure.ac | 16 ++++++++++++++++
lib/pkcs11h-openssl.c | 4 ++++
3 files changed, 21 insertions(+)
diff --git a/configure.ac b/configure.ac
index 716bb8d8..57697a3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -300,7 +300,9 @@ if test "${have_openssl}" = "no"; then
fi
if test "${have_openssl}" = "yes"; then
+ old_CFLAGS="${CFLAGS}"
old_LIBS="${LIBS}"
+ CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
LIBS="${LIBS} ${OPENSSL_LIBS}"
AC_CHECK_FUNCS([ \
RSA_meth_dup RSA_meth_free \
@@ -344,6 +346,20 @@ if test "${have_openssl}" = "yes"; then
)
AC_MSG_CHECKING([for OpenSSL ec support])
AC_MSG_RESULT([${openssl_ec}])
+ # https://github.com/OpenSC/pkcs11-helper/pull/55
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <openssl/dsa.h>]],
+ [[
+ int foo() {
+ DSA_METHOD *meth = NULL;
+ sizeof(meth->name);
+ }
+ ]]
+ )],
+ [AC_DEFINE([HAVE_DSA_METHOD_NAME], [1], [Have DSA_METHOD->name])]
+ )
+ CFLAGS="${old_CFLAGS}"
LIBS="${old_LIBS}"
fi
diff --git a/lib/pkcs11h-openssl.c b/lib/pkcs11h-openssl.c
index 961c955c..38ee8e2d 100644
--- a/lib/pkcs11h-openssl.c
+++ b/lib/pkcs11h-openssl.c
@@ -235,9 +235,13 @@ DSA_meth_free (DSA_METHOD *meth)
static int
DSA_meth_set1_name (DSA_METHOD *meth, const char *name)
{
+#ifdef HAVE_DSA_METHOD_NAME
CK_RV rv;
rv = _pkcs11h_mem_strdup ((void *)&meth->name, name);
return rv == CKR_OK ? 1 : 0;
+#else
+ return 0;
+#endif
}
#endif