Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
To: buildroot@buildroot.org
Cc: Peter Seiderer <ps.report@gmx.net>,
	Fabrice Fontaine <fontaine.fabrice@gmail.com>
Subject: [Buildroot] [PATCH 1/1] package/ntpsec: fix libressl build
Date: Sun, 14 Aug 2022 10:43:00 +0200	[thread overview]
Message-ID: <20220814084300.2782305-1-fontaine.fabrice@gmail.com> (raw)

Fix the following libressl build failure raised since the addition of
the package in commit 27b8d0ba8c4004819e092fb81c0f64f284b3aa4a:

/home/buildroot/autobuild/instance-0/output-1/host/lib/gcc/armeb-buildroot-linux-gnueabi/11.3.0/../../../../armeb-buildroot-linux-gnueabi/bin/ld: libntp/libntp.a(ntp_random.c.1.o): in function `ntp_RAND_priv_bytes':
ntp_random.c:(.text+0xac): undefined reference to `RAND_priv_bytes'

Fixes:
 - http://autobuild.buildroot.org/results/a6a825b7f0efc7c82e8ecf792a1f9951ffb047c5

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 .../ntpsec/0003-fix-build-with-libressl.patch | 80 +++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 package/ntpsec/0003-fix-build-with-libressl.patch

diff --git a/package/ntpsec/0003-fix-build-with-libressl.patch b/package/ntpsec/0003-fix-build-with-libressl.patch
new file mode 100644
index 0000000000..a5c9543157
--- /dev/null
+++ b/package/ntpsec/0003-fix-build-with-libressl.patch
@@ -0,0 +1,80 @@
+From 743f16fb3fed9a05e601226f184be236614efe9a Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Fri, 12 Aug 2022 23:35:52 +0200
+Subject: [PATCH] fix build with libressl
+
+Fix the following build failure with libressl:
+
+/home/buildroot/autobuild/instance-0/output-1/host/lib/gcc/armeb-buildroot-linux-gnueabi/11.3.0/../../../../armeb-buildroot-linux-gnueabi/bin/ld: libntp/libntp.a(ntp_random.c.1.o): in function `ntp_RAND_priv_bytes':
+ntp_random.c:(.text+0xac): undefined reference to `RAND_priv_bytes'
+
+Fixes:
+ - http://autobuild.buildroot.org/results/a6a825b7f0efc7c82e8ecf792a1f9951ffb047c5
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status:
+https://gitlab.com/NTPsec/ntpsec/-/merge_requests/1285]
+---
+ attic/cmac-timing.c | 2 ++
+ attic/random.c      | 8 ++++++++
+ libntp/ntp_random.c | 2 +-
+ 3 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/attic/cmac-timing.c b/attic/cmac-timing.c
+index 464daa76b..4f2fd3338 100644
+--- a/attic/cmac-timing.c
++++ b/attic/cmac-timing.c
+@@ -204,7 +204,9 @@ static void DoPKEY(
+ 		printf("## Oops, EVP_MD_CTX_new() failed.\n");
+ 		return;
+ 	}
++#ifdef EVP_MD_CTX_FLAG_FINALISE
+ 	EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_FINALISE);
++#endif
+ 
+ 	clock_gettime(CLOCK_MONOTONIC, &start);
+ 	for (int i = 0; i < SAMPLESIZE; i++) {
+diff --git a/attic/random.c b/attic/random.c
+index 446c68535..8530ecd25 100644
+--- a/attic/random.c
++++ b/attic/random.c
+@@ -127,7 +127,11 @@ static int do_avg_priv(unsigned int bytes) {
+ 
+ 	clock_gettime(CLOCK_REALTIME, &start);
+ 	for (int i = 0; i < BATCHSIZE; i++) {
++#ifdef LIBRESSL_VERSION_NUMBER
++            err += RAND_bytes((unsigned char *)&rnd, bytes);
++#else
+             err += RAND_priv_bytes((unsigned char *)&rnd, bytes);
++#endif
+ 	}
+ 	clock_gettime(CLOCK_REALTIME, &stop);
+ 
+@@ -209,7 +213,11 @@ static int do_fast_priv(unsigned bytes) {
+ 
+ 	for (int i = 0; i < BATCHSIZE; i++) {
+                 clock_gettime(CLOCK_REALTIME, &start);
++#ifdef LIBRESSL_VERSION_NUMBER
++                err += RAND_bytes((unsigned char *)&rnd, bytes);
++#else
+                 err += RAND_priv_bytes((unsigned char *)&rnd, bytes);
++#endif
+ 		clock_gettime(CLOCK_REALTIME, &stop);
+ 		sec = (stop.tv_sec-start.tv_sec);
+ 		nanos = sec*BILLION + (stop.tv_nsec-start.tv_nsec);
+diff --git a/libntp/ntp_random.c b/libntp/ntp_random.c
+index 9304a790d..adb375b24 100644
+--- a/libntp/ntp_random.c
++++ b/libntp/ntp_random.c
+@@ -29,7 +29,7 @@ void ntp_RAND_bytes(unsigned char *buf, int num) {
+ 
+ void ntp_RAND_priv_bytes(unsigned char *buf, int num) {
+ 	int err;
+-#if (OPENSSL_VERSION_NUMBER > 0x1010100fL)
++#if (OPENSSL_VERSION_NUMBER > 0x1010100fL) && !defined(LIBRESSL_VERSION_NUMBER)
+ 	err = RAND_priv_bytes(buf, num);
+ #else
+ 	err = RAND_bytes(buf, num);
+-- 
+2.35.1
+
-- 
2.35.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

             reply	other threads:[~2022-08-14  8:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-14  8:43 Fabrice Fontaine [this message]
2022-08-14 17:39 ` [Buildroot] [PATCH 1/1] package/ntpsec: fix libressl build Yann E. MORIN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220814084300.2782305-1-fontaine.fabrice@gmail.com \
    --to=fontaine.fabrice@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=ps.report@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox