diff options
author | deraadt <> | 2014-05-29 21:42:44 +0000 |
---|---|---|
committer | deraadt <> | 2014-05-29 21:42:44 +0000 |
commit | 1c7ad5f7b555388d332cd8df7433a71b958e3fa2 (patch) | |
tree | 7efe3e7394ad0a0d226925d3a9fb5501c42e6e2c | |
parent | ff5871ed21b25e74798fe7c0a70a8d9fdccfa20d (diff) | |
download | openbsd-1c7ad5f7b555388d332cd8df7433a71b958e3fa2.tar.gz openbsd-1c7ad5f7b555388d332cd8df7433a71b958e3fa2.tar.bz2 openbsd-1c7ad5f7b555388d332cd8df7433a71b958e3fa2.zip |
I do not have time to describe how bad the realloc() uses in here, now
being relaced by reallocarray(). you will have to look at the diff.
there can be no explanations for the extra casts. as beck says,
"Don't go towards the light theo!"
ok beck tedu
-rw-r--r-- | src/lib/libcrypto/lhash/lhash.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/lhash/lhash.c | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c index 1e3359cfe0..932391fa1e 100644 --- a/src/lib/libcrypto/lhash/lhash.c +++ b/src/lib/libcrypto/lhash/lhash.c | |||
@@ -337,8 +337,7 @@ expand(_LHASH *lh) | |||
337 | 337 | ||
338 | if ((lh->p) >= lh->pmax) { | 338 | if ((lh->p) >= lh->pmax) { |
339 | j = (int)lh->num_alloc_nodes * 2; | 339 | j = (int)lh->num_alloc_nodes * 2; |
340 | n = (LHASH_NODE **)realloc(lh->b, | 340 | n = reallocarray(lh->b, j, sizeof(LHASH_NODE *)); |
341 | (int)(sizeof(LHASH_NODE *) * j)); | ||
342 | if (n == NULL) { | 341 | if (n == NULL) { |
343 | /* fputs("realloc error in lhash", stderr); */ | 342 | /* fputs("realloc error in lhash", stderr); */ |
344 | lh->error++; | 343 | lh->error++; |
@@ -364,8 +363,7 @@ contract(_LHASH *lh) | |||
364 | np = lh->b[lh->p + lh->pmax - 1]; | 363 | np = lh->b[lh->p + lh->pmax - 1]; |
365 | lh->b[lh->p+lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ | 364 | lh->b[lh->p+lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ |
366 | if (lh->p == 0) { | 365 | if (lh->p == 0) { |
367 | n = (LHASH_NODE **)realloc(lh->b, | 366 | n = reallocarray(lh->b, lh->pmax, sizeof(LHASH_NODE *)); |
368 | (unsigned int)(sizeof(LHASH_NODE *) * lh->pmax)); | ||
369 | if (n == NULL) { | 367 | if (n == NULL) { |
370 | /* fputs("realloc error in lhash", stderr); */ | 368 | /* fputs("realloc error in lhash", stderr); */ |
371 | lh->error++; | 369 | lh->error++; |
diff --git a/src/lib/libssl/src/crypto/lhash/lhash.c b/src/lib/libssl/src/crypto/lhash/lhash.c index 1e3359cfe0..932391fa1e 100644 --- a/src/lib/libssl/src/crypto/lhash/lhash.c +++ b/src/lib/libssl/src/crypto/lhash/lhash.c | |||
@@ -337,8 +337,7 @@ expand(_LHASH *lh) | |||
337 | 337 | ||
338 | if ((lh->p) >= lh->pmax) { | 338 | if ((lh->p) >= lh->pmax) { |
339 | j = (int)lh->num_alloc_nodes * 2; | 339 | j = (int)lh->num_alloc_nodes * 2; |
340 | n = (LHASH_NODE **)realloc(lh->b, | 340 | n = reallocarray(lh->b, j, sizeof(LHASH_NODE *)); |
341 | (int)(sizeof(LHASH_NODE *) * j)); | ||
342 | if (n == NULL) { | 341 | if (n == NULL) { |
343 | /* fputs("realloc error in lhash", stderr); */ | 342 | /* fputs("realloc error in lhash", stderr); */ |
344 | lh->error++; | 343 | lh->error++; |
@@ -364,8 +363,7 @@ contract(_LHASH *lh) | |||
364 | np = lh->b[lh->p + lh->pmax - 1]; | 363 | np = lh->b[lh->p + lh->pmax - 1]; |
365 | lh->b[lh->p+lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ | 364 | lh->b[lh->p+lh->pmax - 1] = NULL; /* 24/07-92 - eay - weird but :-( */ |
366 | if (lh->p == 0) { | 365 | if (lh->p == 0) { |
367 | n = (LHASH_NODE **)realloc(lh->b, | 366 | n = reallocarray(lh->b, lh->pmax, sizeof(LHASH_NODE *)); |
368 | (unsigned int)(sizeof(LHASH_NODE *) * lh->pmax)); | ||
369 | if (n == NULL) { | 367 | if (n == NULL) { |
370 | /* fputs("realloc error in lhash", stderr); */ | 368 | /* fputs("realloc error in lhash", stderr); */ |
371 | lh->error++; | 369 | lh->error++; |