summaryrefslogtreecommitdiff
path: root/Cryptlib/OpenSSL/crypto/lhash
diff options
context:
space:
mode:
authorGary Ching-Pang Lin <glin@suse.com>2015-07-28 11:46:38 -0400
committerPeter Jones <pjones@redhat.com>2015-07-28 11:46:38 -0400
commit5ce38c90cf43ee79cd999716ea83a5a44eeb819e (patch)
tree2fb3d9dd667c772fae5f87fa61e1501cf12da0ce /Cryptlib/OpenSSL/crypto/lhash
parent69ba24ff72921ecabbb47178de40dc5a79350040 (diff)
downloadefi-boot-shim-5ce38c90cf43ee79cd999716ea83a5a44eeb819e.tar.gz
efi-boot-shim-5ce38c90cf43ee79cd999716ea83a5a44eeb819e.zip
Update openssl to 1.0.2d
Also update Cryptlib to edk2 r17731 Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
Diffstat (limited to 'Cryptlib/OpenSSL/crypto/lhash')
-rw-r--r--Cryptlib/OpenSSL/crypto/lhash/lh_stats.c12
-rw-r--r--Cryptlib/OpenSSL/crypto/lhash/lhash.c99
2 files changed, 56 insertions, 55 deletions
diff --git a/Cryptlib/OpenSSL/crypto/lhash/lh_stats.c b/Cryptlib/OpenSSL/crypto/lhash/lh_stats.c
index 2e87a462..0bfec232 100644
--- a/Cryptlib/OpenSSL/crypto/lhash/lh_stats.c
+++ b/Cryptlib/OpenSSL/crypto/lhash/lh_stats.c
@@ -138,7 +138,7 @@ void lh_node_usage_stats(LHASH *lh, FILE *out)
#else
# ifndef OPENSSL_NO_FP_API
-void lh_stats(const LHASH *lh, FILE *fp)
+void lh_stats(const _LHASH *lh, FILE *fp)
{
BIO *bp;
@@ -151,7 +151,7 @@ void lh_stats(const LHASH *lh, FILE *fp)
end:;
}
-void lh_node_stats(const LHASH *lh, FILE *fp)
+void lh_node_stats(const _LHASH *lh, FILE *fp)
{
BIO *bp;
@@ -164,7 +164,7 @@ void lh_node_stats(const LHASH *lh, FILE *fp)
end:;
}
-void lh_node_usage_stats(const LHASH *lh, FILE *fp)
+void lh_node_usage_stats(const _LHASH *lh, FILE *fp)
{
BIO *bp;
@@ -179,7 +179,7 @@ void lh_node_usage_stats(const LHASH *lh, FILE *fp)
# endif
-void lh_stats_bio(const LHASH *lh, BIO *out)
+void lh_stats_bio(const _LHASH *lh, BIO *out)
{
BIO_printf(out, "num_items = %lu\n", lh->num_items);
BIO_printf(out, "num_nodes = %u\n", lh->num_nodes);
@@ -206,7 +206,7 @@ void lh_stats_bio(const LHASH *lh, BIO *out)
# endif
}
-void lh_node_stats_bio(const LHASH *lh, BIO *out)
+void lh_node_stats_bio(const _LHASH *lh, BIO *out)
{
LHASH_NODE *n;
unsigned int i, num;
@@ -218,7 +218,7 @@ void lh_node_stats_bio(const LHASH *lh, BIO *out)
}
}
-void lh_node_usage_stats_bio(const LHASH *lh, BIO *out)
+void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out)
{
LHASH_NODE *n;
unsigned long num;
diff --git a/Cryptlib/OpenSSL/crypto/lhash/lhash.c b/Cryptlib/OpenSSL/crypto/lhash/lhash.c
index d48fe562..53c5c138 100644
--- a/Cryptlib/OpenSSL/crypto/lhash/lhash.c
+++ b/Cryptlib/OpenSSL/crypto/lhash/lhash.c
@@ -108,20 +108,18 @@ const char lh_version[] = "lhash" OPENSSL_VERSION_PTEXT;
#define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */
#define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */
-static void expand(LHASH *lh);
-static void contract(LHASH *lh);
-static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash);
+static void expand(_LHASH *lh);
+static void contract(_LHASH *lh);
+static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash);
-LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
+_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
{
- LHASH *ret;
+ _LHASH *ret;
int i;
- if ((ret = (LHASH *)OPENSSL_malloc(sizeof(LHASH))) == NULL)
+ if ((ret = OPENSSL_malloc(sizeof(_LHASH))) == NULL)
goto err0;
- if ((ret->b =
- (LHASH_NODE **)OPENSSL_malloc(sizeof(LHASH_NODE *) * MIN_NODES)) ==
- NULL)
+ if ((ret->b = OPENSSL_malloc(sizeof(LHASH_NODE *) * MIN_NODES)) == NULL)
goto err1;
for (i = 0; i < MIN_NODES; i++)
ret->b[i] = NULL;
@@ -157,7 +155,7 @@ LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)
return (NULL);
}
-void lh_free(LHASH *lh)
+void lh_free(_LHASH *lh)
{
unsigned int i;
LHASH_NODE *n, *nn;
@@ -177,7 +175,7 @@ void lh_free(LHASH *lh)
OPENSSL_free(lh);
}
-void *lh_insert(LHASH *lh, void *data)
+void *lh_insert(_LHASH *lh, void *data)
{
unsigned long hash;
LHASH_NODE *nn, **rn;
@@ -212,7 +210,7 @@ void *lh_insert(LHASH *lh, void *data)
return (ret);
}
-void *lh_delete(LHASH *lh, const void *data)
+void *lh_delete(_LHASH *lh, const void *data)
{
unsigned long hash;
LHASH_NODE *nn, **rn;
@@ -240,7 +238,7 @@ void *lh_delete(LHASH *lh, const void *data)
return (ret);
}
-void *lh_retrieve(LHASH *lh, const void *data)
+void *lh_retrieve(_LHASH *lh, const void *data)
{
unsigned long hash;
LHASH_NODE **rn;
@@ -259,12 +257,15 @@ void *lh_retrieve(LHASH *lh, const void *data)
return (ret);
}
-static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
+static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
{
int i;
LHASH_NODE *a, *n;
+ if (lh == NULL)
+ return;
+
/*
* reverse the order so we search from 'top to bottom' We were having
* memory leaks otherwise
@@ -275,6 +276,10 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
/*
* 28/05/91 - eay - n added so items can be deleted via lh_doall
*/
+ /*
+ * 22/05/08 - ben - eh? since a is not passed, this should not be
+ * needed
+ */
n = a->next;
if (use_arg)
func_arg(a->data, arg);
@@ -285,51 +290,29 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
}
}
-void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func)
+void lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func)
{
doall_util_fn(lh, 0, func, (LHASH_DOALL_ARG_FN_TYPE)0, NULL);
}
-void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
+void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
{
doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
}
-static void expand(LHASH *lh)
+static void expand(_LHASH *lh)
{
LHASH_NODE **n, **n1, **n2, *np;
- unsigned int p, i, j, pmax;
+ unsigned int p, i, j;
unsigned long hash, nni;
- p = (int)lh->p++;
- nni = lh->num_alloc_nodes;
- pmax = lh->pmax;
-
- if ((lh->p) >= lh->pmax) {
- j = (int)lh->num_alloc_nodes * 2;
- n = (LHASH_NODE **)OPENSSL_realloc(lh->b,
- (int)sizeof(LHASH_NODE *) * j);
- if (n == NULL) {
-/* fputs("realloc error in lhash",stderr); */
- lh->error++;
- lh->p = 0;
- return;
- }
- /* else */
- for (i = (int)lh->num_alloc_nodes; i < j; i++) /* 26/02/92 eay */
- n[i] = NULL; /* 02/03/92 eay */
- lh->pmax = lh->num_alloc_nodes;
- lh->num_alloc_nodes = j;
- lh->num_expand_reallocs++;
- lh->p = 0;
- lh->b = n;
- }
-
lh->num_nodes++;
lh->num_expands++;
+ p = (int)lh->p++;
n1 = &(lh->b[p]);
- n2 = &(lh->b[p + pmax]);
+ n2 = &(lh->b[p + (int)lh->pmax]);
*n2 = NULL; /* 27/07/92 - eay - undefined pointer bug */
+ nni = lh->num_alloc_nodes;
for (np = *n1; np != NULL;) {
#ifndef OPENSSL_NO_HASH_COMP
@@ -347,14 +330,33 @@ static void expand(LHASH *lh)
np = *n1;
}
+ if ((lh->p) >= lh->pmax) {
+ j = (int)lh->num_alloc_nodes * 2;
+ n = (LHASH_NODE **)OPENSSL_realloc(lh->b,
+ (int)(sizeof(LHASH_NODE *) * j));
+ if (n == NULL) {
+/* fputs("realloc error in lhash",stderr); */
+ lh->error++;
+ lh->p = 0;
+ return;
+ }
+ /* else */
+ for (i = (int)lh->num_alloc_nodes; i < j; i++) /* 26/02/92 eay */
+ n[i] = NULL; /* 02/03/92 eay */
+ lh->pmax = lh->num_alloc_nodes;
+ lh->num_alloc_nodes = j;
+ lh->num_expand_reallocs++;
+ lh->p = 0;
+ lh->b = n;
+ }
}
-static void contract(LHASH *lh)
+static void contract(_LHASH *lh)
{
LHASH_NODE **n, *n1, *np;
- int idx = lh->p + lh->pmax - 1;
- np = lh->b[idx];
+ np = lh->b[lh->p + lh->pmax - 1];
+ lh->b[lh->p + lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */
if (lh->p == 0) {
n = (LHASH_NODE **)OPENSSL_realloc(lh->b,
(unsigned int)(sizeof(LHASH_NODE *)
@@ -372,7 +374,6 @@ static void contract(LHASH *lh)
} else
lh->p--;
- lh->b[idx] = NULL;
lh->num_nodes--;
lh->num_contracts++;
@@ -386,7 +387,7 @@ static void contract(LHASH *lh)
}
}
-static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash)
+static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash)
{
LHASH_NODE **ret, *n1;
unsigned long hash, nn;
@@ -451,7 +452,7 @@ unsigned long lh_strhash(const char *c)
return ((ret >> 16) ^ ret);
}
-unsigned long lh_num_items(const LHASH *lh)
+unsigned long lh_num_items(const _LHASH *lh)
{
return lh ? lh->num_items : 0;
}