[Buildroot] [PATCH 1/1] package/ntpsec: fix libressl build
Yann E. MORIN
yann.morin.1998 at free.fr
Sun Aug 14 17:39:54 UTC 2022
Fabrice, All,
On 2022-08-14 10:43 +0200, Fabrice Fontaine spake thusly:
> 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 at gmail.com>
Applied to master, thanks.
Regards,
Yann E. MORIN.
> ---
> .../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 at 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 at 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 at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
More information about the buildroot
mailing list