57708b6f716ed47761ef61d69ccb96ae0ea21693
[gentoo.git] /
1 commit 04b0ac05377936d121a36873bb63d492cde292c9
2 Author: Simon Kelley <simon@thekelleys.org.uk>
3 Date:   Mon Apr 6 17:19:13 2015 +0100
4
5     Fix crash caused by looking up servers.bind when many servers defined.
6
7 diff --git a/src/cache.c b/src/cache.c
8 index d7bea57..178d654 100644
9 --- a/src/cache.c
10 +++ b/src/cache.c
11 @@ -1367,7 +1367,7 @@ int cache_make_stat(struct txt_record *t)
12                 }
13             port = prettyprint_addr(&serv->addr, daemon->addrbuff);
14             lenp = p++; /* length */
15 -           bytes_avail = (p - buff) + bufflen;
16 +           bytes_avail = bufflen - (p - buff );
17             bytes_needed = snprintf(p, bytes_avail, "%s#%d %u %u", daemon->addrbuff, port, queries, failed_queries);
18             if (bytes_needed >= bytes_avail)
19               {
20 @@ -1381,7 +1381,7 @@ int cache_make_stat(struct txt_record *t)
21                 lenp = p - 1;
22                 buff = new;
23                 bufflen = newlen;
24 -               bytes_avail = (p - buff) + bufflen;
25 +               bytes_avail =  bufflen - (p - buff );
26                 bytes_needed = snprintf(p, bytes_avail, "%s#%d %u %u", daemon->addrbuff, port, queries, failed_queries);
27               }
28             *lenp = bytes_needed;