Hi again,

We at Fedora use dynamic linking for all libraries. We had breakage of
dnsmasq build more than once, because dnsmasq is using directly
nettle_hash array. If its size changes, dynamic linker will refuse to
link it. For that reason, accessing hash array directly makes trouble.
There is however special function that looks like very similar to
hash_find() of dnsmasq, that iterates the array internally. It requires
nettle 3.4, but I think that is already old enough. It would help
preventing any more linker conflict, if library data changes.

Do you think older library version should be supported as well?

Best regards,
-- 
Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: pemen...@redhat.com  PGP: 65C6C973
From d7bcf644ac2e7ccfa0a1a9e42d92507ce6e9bb6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemen...@redhat.com>
Date: Mon, 26 Feb 2018 20:52:33 +0100
Subject: [PATCH] Do not use nettle_hashes, use function for hash lookup
 provided by library.

---
 src/crypto.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/crypto.c b/src/crypto.c
index 16ef1ca..4bd4d43 100644
--- a/src/crypto.c
+++ b/src/crypto.c
@@ -109,22 +109,15 @@ static struct nettle_hash null_hash = {
 /* Find pointer to correct hash function in nettle library */
 const struct nettle_hash *hash_find(char *name)
 {
-  int i;
-  
   if (!name)
     return NULL;
-  
-  for (i = 0; nettle_hashes[i]; i++)
-    {
-      if (strcmp(nettle_hashes[i]->name, name) == 0)
-	return nettle_hashes[i];
-    }
-
+ 
   /* We provide a "null" hash which returns the input data as digest. */
-  if (strcmp(null_hash.name, name) == 0)
+  if (strcmp(null_hash.name, name) == 0) {
     return &null_hash;
-
-  return NULL;
+  } else {
+    return nettle_lookup_hash(name);
+  }
 }
 
 /* expand ctx and digest memory allocations if necessary and init hash function */
-- 
2.14.3

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to