git: ee81e15571ac - main - security/rnp: fix build using c++19 include files

From: Stefan Eßer <se_at_FreeBSD.org>
Date: Wed, 26 Feb 2025 12:57:59 UTC
The branch main has been updated by se:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ee81e15571ac5999462e6049d74743909e10a2b8

commit ee81e15571ac5999462e6049d74743909e10a2b8
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2025-02-26 12:43:08 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2025-02-26 12:43:08 +0000

    security/rnp: fix build using c++19 include files
    
    The build failed with:
    
        libcxx: error: implicit instantiation of undefined template
        'std::char_traits<unsigned char>
    
    This was caused by a restriction of char_traits to a subset of the
    integer types that used to be supported (e.g. char, wchar_t), which
    no longer includes the type unsigned char.
    
    There has been no new release, yet, but upstream fixed this issue
    in commit 20419f7.
    
    PR:             282348
    Reported by:    jkim
    Obtained from:  https://github.com/rnpgp/rnp/commit/20419f7
---
 security/rnp/Makefile                              |  3 +-
 security/rnp/distinfo                              |  6 ++--
 security/rnp/files/patch-src_lib_types.h           | 19 +++++++++++++
 security/rnp/files/patch-src_lib_utils.cpp         | 31 ++++++++++++++++++++
 .../files/patch-src_librekey_key__store__g10.cpp   | 33 ++++++++++++++++++++++
 5 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/security/rnp/Makefile b/security/rnp/Makefile
index a50d587a469c..cf891e18c130 100644
--- a/security/rnp/Makefile
+++ b/security/rnp/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	rnp
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.17.1
+PORTREVISION=	1
 CATEGORIES=	security
 
 MAINTAINER=	se@FreeBSD.org
@@ -22,7 +23,7 @@ LIB_DEPENDS=	libbotan-2.so:security/botan2 \
 USES=		cmake compiler:c++11-lang pkgconfig
 USE_GITHUB=	yes
 GH_ACCOUNT=	rnpgp
-GH_TUPLE=	rnpgp:sexpp:e265f63:sexpp/src/libsexpp
+GH_TUPLE=	rnpgp:sexpp:c641a2f:sexpp/src/libsexpp
 USE_LDCONFIG=	yes
 
 CMAKE_ARGS=	-DBUILD_SHARED_LIBS=on \
diff --git a/security/rnp/distinfo b/security/rnp/distinfo
index 209f64902d34..2689cd70a2ce 100644
--- a/security/rnp/distinfo
+++ b/security/rnp/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1717402611
+TIMESTAMP = 1740573395
 SHA256 (rnpgp-rnp-v0.17.1_GH0.tar.gz) = ec486bb2c25abb0ddbd95973fd135e3922ea68b4e6919c7c18d992078baaf50c
 SIZE (rnpgp-rnp-v0.17.1_GH0.tar.gz) = 3515288
-SHA256 (rnpgp-sexpp-e265f63_GH0.tar.gz) = 8304ea28d5006b1ae5e115b6e67e3d5a75cf711517f6c40036dce19c0802fd07
-SIZE (rnpgp-sexpp-e265f63_GH0.tar.gz) = 46972
+SHA256 (rnpgp-sexpp-c641a2f_GH0.tar.gz) = 43d4abdb0c131305ed11ce202d128717336782159b741931494ee8f99cf43cf4
+SIZE (rnpgp-sexpp-c641a2f_GH0.tar.gz) = 71645
diff --git a/security/rnp/files/patch-src_lib_types.h b/security/rnp/files/patch-src_lib_types.h
new file mode 100644
index 000000000000..4262e8f2de42
--- /dev/null
+++ b/security/rnp/files/patch-src_lib_types.h
@@ -0,0 +1,19 @@
+--- src/lib/types.h.orig	2024-05-03 10:03:14 UTC
++++ src/lib/types.h
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2017-2021, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2017-2024, [Ribose Inc](https://www.ribose.com).
+  * Copyright (c) 2009 The NetBSD Foundation, Inc.
+  * All rights reserved.
+  *
+@@ -95,9 +95,6 @@ class id_str_pair {
+     static int         lookup(const id_str_pair           pair[],
+                               const std::vector<uint8_t> &bytes,
+                               int                         notfound = 0);
+-    static int         lookup(const id_str_pair                 pair[],
+-                              const std::basic_string<uint8_t> &bytes,
+-                              int                               notfound = 0);
+ };
+ 
+ /** pgp_fingerprint_t */
diff --git a/security/rnp/files/patch-src_lib_utils.cpp b/security/rnp/files/patch-src_lib_utils.cpp
new file mode 100644
index 000000000000..761f5bd55c94
--- /dev/null
+++ b/security/rnp/files/patch-src_lib_utils.cpp
@@ -0,0 +1,31 @@
+--- src/lib/utils.cpp.orig	2024-05-03 10:03:14 UTC
++++ src/lib/utils.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2021, 2024 [Ribose Inc](https://www.ribose.com).
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+@@ -53,21 +53,6 @@ id_str_pair::lookup(const id_str_pair pair[], const st
+ 
+ int
+ id_str_pair::lookup(const id_str_pair pair[], const std::vector<uint8_t> &bytes, int notfound)
+-{
+-    while (pair && pair->str) {
+-        if ((strlen(pair->str) == bytes.size()) &&
+-            !memcmp(pair->str, bytes.data(), bytes.size())) {
+-            return pair->id;
+-        }
+-        pair++;
+-    }
+-    return notfound;
+-}
+-
+-int
+-id_str_pair::lookup(const id_str_pair                 pair[],
+-                    const std::basic_string<uint8_t> &bytes,
+-                    int                               notfound)
+ {
+     while (pair && pair->str) {
+         if ((strlen(pair->str) == bytes.size()) &&
diff --git a/security/rnp/files/patch-src_librekey_key__store__g10.cpp b/security/rnp/files/patch-src_librekey_key__store__g10.cpp
new file mode 100644
index 000000000000..688b54c380e4
--- /dev/null
+++ b/security/rnp/files/patch-src_librekey_key__store__g10.cpp
@@ -0,0 +1,33 @@
+--- src/librekey/key_store_g10.cpp.orig	2024-05-03 10:03:14 UTC
++++ src/librekey/key_store_g10.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2017-2022, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2017-2024, [Ribose Inc](https://www.ribose.com).
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+@@ -312,12 +312,12 @@ read_curve(const sexp_list_t *list, const std::string 
+ 
+     const auto &bytes = data->get_string();
+     pgp_curve_t curve = static_cast<pgp_curve_t>(
+-      id_str_pair::lookup(g10_curve_aliases, data->get_string(), PGP_CURVE_UNKNOWN));
++      id_str_pair::lookup(g10_curve_aliases, (const char *) bytes.data(), PGP_CURVE_UNKNOWN));
+     if (curve != PGP_CURVE_UNKNOWN) {
+         key.curve = curve;
+         return true;
+     }
+-    RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (char *) bytes.data());
++    RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (const char *) bytes.data());
+     return false;
+ }
+ 
+@@ -806,7 +806,7 @@ g23_parse_seckey(pgp_key_pkt_t &seckey,
+ 
+     auto &           alg_bt = alg_s_exp->sexp_string_at(0)->get_string();
+     pgp_pubkey_alg_t alg = static_cast<pgp_pubkey_alg_t>(
+-      id_str_pair::lookup(g10_alg_aliases, alg_bt.c_str(), PGP_PKA_NOTHING));
++      id_str_pair::lookup(g10_alg_aliases, (const char *) alg_bt.data(), PGP_PKA_NOTHING));
+     if (alg == PGP_PKA_NOTHING) {
+         RNP_LOG(
+           "Unsupported algorithm: '%.*s'", (int) alg_bt.size(), (const char *) alg_bt.data());