Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
8d718cbb
Commit
8d718cbb
authored
Feb 03, 2014
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nasty cache failure and memory leak with DNSSEC.
parent
f6a2b793
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
215 additions
and
136 deletions
+215
-136
src/blockdata.c
src/blockdata.c
+25
-15
src/cache.c
src/cache.c
+23
-5
src/dnssec.c
src/dnssec.c
+167
-116
No files found.
src/blockdata.c
View file @
8d718cbb
...
@@ -21,20 +21,33 @@
...
@@ -21,20 +21,33 @@
static
struct
blockdata
*
keyblock_free
;
static
struct
blockdata
*
keyblock_free
;
static
unsigned
int
blockdata_count
,
blockdata_hwm
,
blockdata_alloced
;
static
unsigned
int
blockdata_count
,
blockdata_hwm
,
blockdata_alloced
;
/* Preallocate some blocks, proportional to cachesize, to reduce heap fragmentation. */
static
void
blockdata_expand
(
int
n
)
void
blockdata_init
(
void
)
{
{
struct
blockdata
*
new
=
whine_malloc
(
n
*
sizeof
(
struct
blockdata
));
if
(
new
)
{
int
i
;
int
i
;
blockdata_alloced
=
(
daemon
->
cachesize
*
100
)
/
sizeof
(
struct
blockdata
);
new
[
n
-
1
].
next
=
keyblock_free
;
keyblock_free
=
new
;
keyblock_free
=
safe_malloc
(
blockdata_alloced
*
sizeof
(
struct
blockdata
));
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
keyblock_free
[
blockdata_alloced
-
1
].
next
=
NULL
;
new
[
i
].
next
=
&
new
[
i
+
1
];
for
(
i
=
0
;
i
<
blockdata_alloced
-
1
;
i
++
)
keyblock_free
[
i
].
next
=
&
keyblock_free
[
i
+
1
];
blockdata_alloced
+=
n
;
}
}
/* Preallocate some blocks, proportional to cachesize, to reduce heap fragmentation. */
void
blockdata_init
(
void
)
{
keyblock_free
=
NULL
;
blockdata_alloced
=
0
;
blockdata_count
=
0
;
blockdata_count
=
0
;
blockdata_hwm
=
0
;
blockdata_hwm
=
0
;
blockdata_expand
((
daemon
->
cachesize
*
100
)
/
sizeof
(
struct
blockdata
));
}
}
void
blockdata_report
(
void
)
void
blockdata_report
(
void
)
...
@@ -51,18 +64,15 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
...
@@ -51,18 +64,15 @@ struct blockdata *blockdata_alloc(char *data, size_t len)
while
(
len
>
0
)
while
(
len
>
0
)
{
{
if
(
!
keyblock_free
)
blockdata_expand
(
50
);
if
(
keyblock_free
)
if
(
keyblock_free
)
{
{
block
=
keyblock_free
;
block
=
keyblock_free
;
keyblock_free
=
block
->
next
;
keyblock_free
=
block
->
next
;
blockdata_count
++
;
blockdata_count
++
;
}
}
else
if
((
block
=
whine_malloc
(
sizeof
(
struct
blockdata
))))
{
blockdata_count
++
;
if
(
blockdata_alloced
<
blockdata_count
)
blockdata_alloced
=
blockdata_count
;
}
if
(
!
block
)
if
(
!
block
)
{
{
...
...
src/cache.c
View file @
8d718cbb
...
@@ -486,14 +486,32 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
...
@@ -486,14 +486,32 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
insert. Once in this state, all inserts will probably fail. */
insert. Once in this state, all inserts will probably fail. */
if
(
free_avail
)
if
(
free_avail
)
{
{
static
warned
=
0
;
if
(
!
warned
)
{
my_syslog
(
LOG_ERR
,
_
(
"Internal error in cache."
));
warned
=
1
;
}
insert_error
=
1
;
insert_error
=
1
;
return
NULL
;
return
NULL
;
}
}
if
(
freed_all
)
if
(
freed_all
)
{
{
struct
all_addr
free_addr
=
new
->
addr
.
addr
;;
#ifdef HAVE_DNSSEC
/* For DNSSEC records, addr holds class and type_covered for RRSIG */
if
(
new
->
flags
&
(
F_DS
|
F_DNSKEY
))
{
free_addr
.
addr
.
dnssec
.
class
=
new
->
uid
;
if
((
new
->
flags
&
(
F_DS
|
F_DNSKEY
))
==
(
F_DS
|
F_DNSKEY
))
free_addr
.
addr
.
dnssec
.
type
=
new
->
addr
.
sig
.
type_covered
;
}
#endif
free_avail
=
1
;
/* Must be free space now. */
free_avail
=
1
;
/* Must be free space now. */
cache_scan_free
(
cache_get_name
(
new
),
&
new
->
addr
.
addr
,
now
,
new
->
flags
);
cache_scan_free
(
cache_get_name
(
new
),
&
free_
addr
,
now
,
new
->
flags
);
cache_live_freed
++
;
cache_live_freed
++
;
}
}
else
else
...
@@ -505,7 +523,7 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
...
@@ -505,7 +523,7 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
}
}
/* Check if we need to and can allocate extra memory for a long name.
/* Check if we need to and can allocate extra memory for a long name.
If that fails, give up now. */
If that fails, give up now
, always succeed for DNSSEC records
. */
if
(
name
&&
(
strlen
(
name
)
>
SMALLDNAME
-
1
))
if
(
name
&&
(
strlen
(
name
)
>
SMALLDNAME
-
1
))
{
{
if
(
big_free
)
if
(
big_free
)
...
@@ -513,13 +531,13 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
...
@@ -513,13 +531,13 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
big_name
=
big_free
;
big_name
=
big_free
;
big_free
=
big_free
->
next
;
big_free
=
big_free
->
next
;
}
}
else
if
(
!
bignames_left
||
else
if
(
(
bignames_left
==
0
&&
!
(
flags
&
(
F_DS
|
F_DNSKEY
)))
||
!
(
big_name
=
(
union
bigname
*
)
whine_malloc
(
sizeof
(
union
bigname
))))
!
(
big_name
=
(
union
bigname
*
)
whine_malloc
(
sizeof
(
union
bigname
))))
{
{
insert_error
=
1
;
insert_error
=
1
;
return
NULL
;
return
NULL
;
}
}
else
else
if
(
bignames_left
!=
0
)
bignames_left
--
;
bignames_left
--
;
}
}
...
...
src/dnssec.c
View file @
8d718cbb
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment