summaryrefslogtreecommitdiff
path: root/dev-util/librnp/files/librnp-0.17.1-libcxx-fix.patch
blob: f10e1c5e70462a76ea11ebcfc4b76062c22a6f41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This patch is fetched from upstream https://github.com/rnpgp/rnp
# The patch is added to the tree by <Denis Pronin> dannftk@yandex.ru

From 20419f739f632fb30666650544f0055e8d4f1afa Mon Sep 17 00:00:00 2001
From: Maxim Samsonov <m.samsonov@computer.org>
Date: Wed, 19 Jun 2024 16:52:08 +0300
Subject: [PATCH] Removed lookup against basic_string<uint8_t>

---
 src/lib/types.h                |  5 +----
 src/lib/utils.cpp              | 17 +----------------
 src/librekey/key_store_g10.cpp |  8 ++++----
 src/libsexpp                   |  2 +-
 4 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/src/lib/types.h b/src/lib/types.h
index f0c25d3d..a7eac3a1 100644
--- a/src/lib/types.h
+++ b/src/lib/types.h
@@ -71,9 +71,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/src/lib/utils.cpp b/src/lib/utils.cpp
index 3c6216c6..fd526379 100644
--- a/src/lib/utils.cpp
+++ b/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
@@ -63,18 +63,3 @@ id_str_pair::lookup(const id_str_pair pair[], const std::vector<uint8_t> &bytes,
     }
     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()) &&
-            !memcmp(pair->str, bytes.data(), bytes.size())) {
-            return pair->id;
-        }
-        pair++;
-    }
-    return notfound;
-}
diff --git a/src/librekey/key_store_g10.cpp b/src/librekey/key_store_g10.cpp
index e646f02f..21136866 100644
--- a/src/librekey/key_store_g10.cpp
+++ b/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
@@ -311,12 +311,12 @@ read_curve(const sexp_list_t *list, const std::string &name, pgp_ec_key_t &key)
 
     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;
 }
 
@@ -807,7 +807,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());