From 30e4f472f5a50121e722cee4fda17bdc932545c7 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Thu, 12 Mar 2020 09:07:48 -0500 Subject: [PATCH] Fix HASHSZ in register.c and make a hash collision fatal --- src/register.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/register.c b/src/register.c index a0f1934c8..1f8f50b26 100644 --- a/src/register.c +++ b/src/register.c @@ -156,7 +156,9 @@ struct rig_list }; -#define RIGLSTHASHSZ 16 +// This size has to be > than the max# of rigs for any manufacturer +// A fatal error will occur when running rigctl if this value is too small +#define RIGLSTHASHSZ 256 #define HASH_FUNC(a) ((a)%RIGLSTHASHSZ) @@ -190,15 +192,6 @@ int HAMLIB_API rig_register(const struct rig_caps *caps) __func__, caps->rig_model); -#ifndef DONT_WANT_DUP_CHECK - - if (rig_get_caps(caps->rig_model) != NULL) - { - return -RIG_EINVAL; - } - -#endif - p = (struct rig_list *)malloc(sizeof(struct rig_list)); if (!p) @@ -207,6 +200,11 @@ int HAMLIB_API rig_register(const struct rig_caps *caps) } hval = HASH_FUNC(caps->rig_model); + if(rig_hash_table[hval]) + { + printf("Hash collision!!! Fatal error!!\n"); + exit(1); + } p->caps = caps; // p->handle = NULL; p->next = rig_hash_table[hval];