projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix out-of-bounds reads in __dns_parse
[musl]
/
src
/
search
/
hsearch.c
diff --git
a/src/search/hsearch.c
b/src/search/hsearch.c
index
1dcb4d8
..
2634a67
100644
(file)
--- a/
src/search/hsearch.c
+++ b/
src/search/hsearch.c
@@
-2,7
+2,6
@@
#include <stdlib.h>
#include <string.h>
#include <search.h>
#include <stdlib.h>
#include <string.h>
#include <search.h>
-#include "libc.h"
/*
open addressing hash table with 2^n table size
/*
open addressing hash table with 2^n table size
@@
-42,9
+41,9
@@
static int resize(size_t nel, struct hsearch_data *htab)
{
size_t newsize;
size_t i, j;
{
size_t newsize;
size_t i, j;
+ size_t oldsize = htab->__tab->mask + 1;
ENTRY *e, *newe;
ENTRY *oldtab = htab->__tab->entries;
ENTRY *e, *newe;
ENTRY *oldtab = htab->__tab->entries;
- ENTRY *oldend = htab->__tab->entries + htab->__tab->mask + 1;
if (nel > MAXSIZE)
nel = MAXSIZE;
if (nel > MAXSIZE)
nel = MAXSIZE;
@@
-57,7
+56,7
@@
static int resize(size_t nel, struct hsearch_data *htab)
htab->__tab->mask = newsize - 1;
if (!oldtab)
return 1;
htab->__tab->mask = newsize - 1;
if (!oldtab)
return 1;
- for (e = oldtab; e < old
end
; e++)
+ for (e = oldtab; e < old
tab + oldsize
; e++)
if (e->key) {
for (i=keyhash(e->key),j=1; ; i+=j++) {
newe = htab->__tab->entries + (i & htab->__tab->mask);
if (e->key) {
for (i=keyhash(e->key),j=1; ; i+=j++) {
newe = htab->__tab->entries + (i & htab->__tab->mask);