Skip to content

Commit 4fdf3a8

Browse files
committed
Stuff that came out of valgrind on FreeBSD 12
1 parent 8da6fdb commit 4fdf3a8

File tree

15 files changed

+313
-19
lines changed

15 files changed

+313
-19
lines changed

src/anchor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ void _getdns_start_fetching_ta(
12281228
{
12291229
getdns_return_t r;
12301230
size_t scheduled;
1231-
char tas_hostname[256];
1231+
char tas_hostname[256] = "";
12321232
const char *verify_CA;
12331233
const char *verify_email;
12341234

src/context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,7 @@ static getdns_return_t
34863486
ub_setup_recursing(struct ub_ctx *ctx, getdns_context *context)
34873487
{
34883488
_getdns_rr_iter rr_spc, *rr;
3489-
char ta_str[8192];
3489+
char ta_str[8192] = "";
34903490
int r;
34913491

34923492
if ((r = ub_ctx_set_fwd(ctx, NULL))) {

src/convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ static int _jsmn_get_int(const char *js, jsmntok_t *t, uint32_t *value)
13561356

13571357
static int _jsmn_get_const(const char *js, jsmntok_t *t, uint32_t *value)
13581358
{
1359-
char value_str[80];
1359+
char value_str[80] = "";
13601360
int size = t->end - t->start;
13611361

13621362
if (size <= 0 || size >= (int)sizeof(value_str))

src/dict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static char *_json_ptr_first(const struct mem_funcs *mf,
8383
static struct getdns_dict_item *
8484
_find_dict_item(const getdns_dict *dict, const char *jptr)
8585
{
86-
char first_spc[1024], *first;
86+
char first_spc[1024] = "", *first;
8787
struct getdns_dict_item *d;
8888

8989
first = _json_ptr_first(&dict->mf, jptr,

src/gldns/str2wire.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ gldns_str2wire_rr_buf_internal(const char* str, uint8_t* rr, size_t* len,
737737
{
738738
int status;
739739
int not_there = 0;
740-
char token[GLDNS_MAX_RDFLEN+1];
740+
char token[GLDNS_MAX_RDFLEN+1] = "";
741741
uint32_t ttl = 0;
742742
uint16_t tp = 0, cl = 0;
743743
size_t ddlen = 0;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#! /usr/local/bin/gawk -f
2+
# A script to extract the actual suppression info from the output of (for example) valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all ./minimal
3+
# The desired bits are between ^{ and ^} (including the braces themselves).
4+
# The combined output should either be appended to /usr/lib/valgrind/default.supp, or placed in a .supp of its own
5+
# If the latter, either tell valgrind about it each time with --suppressions=<filename>, or add that line to ~/.valgrindrc
6+
7+
# NB This script uses the |& operator, which I believe is gawk-specific. In case of failure, check that you're using gawk rather than some other awk
8+
9+
# The script looks for suppressions. When it finds one it stores it temporarily in an array,
10+
# and also feeds it line by line to the external app 'md5sum' which generates a unique checksum for it.
11+
# The checksum is used as an index in a different array. If an item with that index already exists the suppression must be a duplicate and is discarded.
12+
13+
BEGIN { suppression=0; md5sum = "md5" }
14+
# If the line begins with '{', it's the start of a supression; so set the var and initialise things
15+
/^{/ {
16+
suppression=1; i=0; next
17+
}
18+
# If the line begins with '}' its the end of a suppression
19+
/^}/ {
20+
if (suppression)
21+
{ suppression=0;
22+
close(md5sum, "to") # We've finished sending data to md5sum, so close that part of the pipe
23+
ProcessInput() # Do the slightly-complicated stuff in functions
24+
delete supparray # We don't want subsequent suppressions to append to it!
25+
}
26+
}
27+
# Otherwise, it's a normal line. If we're inside a supression, store it, and pipe it to md5sum. Otherwise it's cruft, so ignore it
28+
{ if (suppression)
29+
{
30+
supparray[++i] = $0
31+
print |& md5sum
32+
}
33+
}
34+
35+
36+
function ProcessInput()
37+
{
38+
# Pipe the result from md5sum, then close it
39+
md5sum |& getline result
40+
close(md5sum)
41+
# gawk can't cope with enormous ints like $result would be, so stringify it first by prefixing a definite string
42+
resultstring = "prefix"result
43+
44+
if (! (resultstring in chksum_array) )
45+
{ chksum_array[resultstring] = 0; # This checksum hasn't been seen before, so add it to the array
46+
OutputSuppression() # and output the contents of the suppression
47+
}
48+
}
49+
50+
function OutputSuppression()
51+
{
52+
# A suppression is surrounded by '{' and '}'. Its data was stored line by line in the array
53+
print "{"
54+
for (n=1; n <= i; ++n)
55+
{ print supparray[n] }
56+
print "}"
57+
}

src/test/tpkg/125-valgrind-checks.tpkg/125-valgrind-checks.supp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,65 @@
1616
fun:pthread_attr_init
1717
obj:/usr/local/lib/libunbound.so.8.1.5
1818
}
19+
{
20+
<insert_a_suppression_name_here>
21+
Memcheck:Cond
22+
obj:/lib/libc.so.7
23+
obj:/lib/libc.so.7
24+
obj:*
25+
obj:/lib/libc.so.7
26+
obj:*
27+
obj:/lib/libc.so.7
28+
obj:/lib/libc.so.7
29+
obj:/lib/libc.so.7
30+
obj:/root/getdns/tests/build/getdns_query
31+
obj:/lib/libc.so.7
32+
}
33+
{
34+
<insert_a_suppression_name_here>
35+
Memcheck:Cond
36+
obj:/lib/libc.so.7
37+
obj:*
38+
obj:/usr/local/lib/libunbound.so.8.1.5
39+
obj:/usr/local/lib/libunbound.so.8.1.5
40+
obj:/usr/local/lib/libunbound.so.8.1.5
41+
obj:/usr/local/lib/libunbound.so.8.1.5
42+
obj:/usr/local/lib/libunbound.so.8.1.5
43+
obj:/usr/local/lib/libunbound.so.8.1.5
44+
obj:/usr/local/lib/libunbound.so.8.1.5
45+
obj:/usr/local/lib/libunbound.so.8.1.5
46+
fun:_getdns_submit_netreq
47+
fun:getdns_general_ns
48+
}
49+
{
50+
<insert_a_suppression_name_here>
51+
Memcheck:Cond
52+
obj:/lib/libc.so.7
53+
obj:*
54+
obj:/usr/local/lib/libunbound.so.8.1.5
55+
obj:/usr/local/lib/libunbound.so.8.1.5
56+
obj:/usr/local/lib/libunbound.so.8.1.5
57+
obj:/usr/local/lib/libunbound.so.8.1.5
58+
obj:/usr/local/lib/libunbound.so.8.1.5
59+
obj:/usr/local/lib/libunbound.so.8.1.5
60+
obj:/usr/local/lib/libunbound.so.8.1.5
61+
obj:/usr/local/lib/libunbound.so.8.1.5
62+
obj:/usr/local/lib/libunbound.so.8.1.5
63+
fun:_getdns_submit_netreq
64+
}
65+
{
66+
<insert_a_suppression_name_here>
67+
Memcheck:Cond
68+
obj:/lib/libc.so.7
69+
obj:*
70+
obj:/usr/local/lib/libunbound.so.8.1.5
71+
obj:/usr/local/lib/libunbound.so.8.1.5
72+
obj:/usr/local/lib/libunbound.so.8.1.5
73+
obj:/usr/local/lib/libunbound.so.8.1.5
74+
obj:/usr/local/lib/libunbound.so.8.1.5
75+
obj:/usr/local/lib/libunbound.so.8.1.5
76+
obj:/usr/local/lib/libunbound.so.8.1.5
77+
obj:/usr/local/lib/libunbound.so.8.1.5
78+
obj:/usr/local/lib/libunbound.so.8.1.5
79+
obj:/usr/local/lib/libunbound.so.8.1.5
80+
}

src/test/tpkg/125-valgrind-checks.tpkg/125-valgrind-checks.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
# use .tpkg.var.test for in test variable passing
55
[ -f .tpkg.var.test ] && source .tpkg.var.test
66

7+
## To add suppressions:
8+
##
9+
#
10+
# valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes --gen-suppressions=all "${GETDNS_QUERY}" -F "${TPKG_NAME}.queries" -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
11+
# ./${PKG_NAME}.parse_valgrind_suppressions.sh > new_supps
12+
# cat ${PKG_NAME}.supp new_supps > tmp_supps
13+
# mv tmp_supps ${PKG_NAME}.supp
14+
#
15+
716
(
817
if ! valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_QUERY}" -F "${TPKG_NAME}.queries" -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
918
then
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#! /usr/local/bin/gawk -f
2+
# A script to extract the actual suppression info from the output of (for example) valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all ./minimal
3+
# The desired bits are between ^{ and ^} (including the braces themselves).
4+
# The combined output should either be appended to /usr/lib/valgrind/default.supp, or placed in a .supp of its own
5+
# If the latter, either tell valgrind about it each time with --suppressions=<filename>, or add that line to ~/.valgrindrc
6+
7+
# NB This script uses the |& operator, which I believe is gawk-specific. In case of failure, check that you're using gawk rather than some other awk
8+
9+
# The script looks for suppressions. When it finds one it stores it temporarily in an array,
10+
# and also feeds it line by line to the external app 'md5sum' which generates a unique checksum for it.
11+
# The checksum is used as an index in a different array. If an item with that index already exists the suppression must be a duplicate and is discarded.
12+
13+
BEGIN { suppression=0; md5sum = "md5" }
14+
# If the line begins with '{', it's the start of a supression; so set the var and initialise things
15+
/^{/ {
16+
suppression=1; i=0; next
17+
}
18+
# If the line begins with '}' its the end of a suppression
19+
/^}/ {
20+
if (suppression)
21+
{ suppression=0;
22+
close(md5sum, "to") # We've finished sending data to md5sum, so close that part of the pipe
23+
ProcessInput() # Do the slightly-complicated stuff in functions
24+
delete supparray # We don't want subsequent suppressions to append to it!
25+
}
26+
}
27+
# Otherwise, it's a normal line. If we're inside a supression, store it, and pipe it to md5sum. Otherwise it's cruft, so ignore it
28+
{ if (suppression)
29+
{
30+
supparray[++i] = $0
31+
print |& md5sum
32+
}
33+
}
34+
35+
36+
function ProcessInput()
37+
{
38+
# Pipe the result from md5sum, then close it
39+
md5sum |& getline result
40+
close(md5sum)
41+
# gawk can't cope with enormous ints like $result would be, so stringify it first by prefixing a definite string
42+
resultstring = "prefix"result
43+
44+
if (! (resultstring in chksum_array) )
45+
{ chksum_array[resultstring] = 0; # This checksum hasn't been seen before, so add it to the array
46+
OutputSuppression() # and output the contents of the suppression
47+
}
48+
}
49+
50+
function OutputSuppression()
51+
{
52+
# A suppression is surrounded by '{' and '}'. Its data was stored line by line in the array
53+
print "{"
54+
for (n=1; n <= i; ++n)
55+
{ print supparray[n] }
56+
print "}"
57+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NS .
2+
-A getdnsapi.net
3+
qwerlkjhasdfpuiqwyerm.1234kjhrqwersv.com
4+
-G TXT bogus.nlnetlabs.nl
5+
-H 8.8.8.8
6+
-H 2a04:b900:0:100::37
7+
-A _acme-challenge.getdnsapi.net
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
{
3+
<insert_a_suppression_name_here>
4+
Memcheck:Cond
5+
obj:/lib/libc.so.7
6+
obj:/lib/libc.so.7
7+
obj:*
8+
obj:/lib/libc.so.7
9+
obj:*
10+
obj:/lib/libc.so.7
11+
obj:/lib/libc.so.7
12+
obj:/lib/libc.so.7
13+
obj:/root/getdns/tests/build-stub-only/getdns_query
14+
obj:/lib/libc.so.7
15+
}
16+
{
17+
<insert_a_suppression_name_here>
18+
Memcheck:Cond
19+
obj:/lib/libc.so.7
20+
obj:*
21+
obj:/lib/libc.so.7
22+
}
23+
{
24+
<insert_a_suppression_name_here>
25+
Memcheck:Cond
26+
obj:/lib/libc.so.7
27+
obj:*
28+
fun:strcpytrunc
29+
fun:ta_iter_next
30+
fun:ta_iter_init
31+
fun:_getdns_parse_xml_trust_anchors_buf
32+
fun:_getdns_context_equip_with_anchor
33+
fun:getdns_general_ns
34+
fun:_getdns_general_loop
35+
fun:getdns_general_sync
36+
fun:do_the_call
37+
fun:read_line_cb
38+
}
39+
{
40+
<insert_a_suppression_name_here>
41+
Memcheck:Cond
42+
obj:/lib/libc.so.7
43+
obj:*
44+
fun:strcpytrunc
45+
fun:ta_iter_next
46+
fun:_getdns_parse_xml_trust_anchors_buf
47+
fun:_getdns_context_equip_with_anchor
48+
fun:getdns_general_ns
49+
fun:_getdns_general_loop
50+
fun:getdns_general_sync
51+
fun:do_the_call
52+
fun:read_line_cb
53+
fun:poll_read_cb
54+
}
55+
{
56+
<insert_a_suppression_name_here>
57+
Memcheck:Cond
58+
obj:/lib/libc.so.7
59+
obj:*
60+
obj:/usr/local/lib/libunbound.so.8.1.5
61+
obj:/usr/local/lib/libunbound.so.8.1.5
62+
obj:/usr/local/lib/libunbound.so.8.1.5
63+
obj:/usr/local/lib/libunbound.so.8.1.5
64+
obj:/usr/local/lib/libunbound.so.8.1.5
65+
obj:/usr/local/lib/libunbound.so.8.1.5
66+
obj:/usr/local/lib/libunbound.so.8.1.5
67+
obj:/usr/local/lib/libunbound.so.8.1.5
68+
fun:_getdns_submit_netreq
69+
fun:getdns_general_ns
70+
}
71+
{
72+
<insert_a_suppression_name_here>
73+
Memcheck:Cond
74+
obj:/lib/libc.so.7
75+
obj:*
76+
obj:/usr/local/lib/libunbound.so.8.1.5
77+
obj:/usr/local/lib/libunbound.so.8.1.5
78+
obj:/usr/local/lib/libunbound.so.8.1.5
79+
obj:/usr/local/lib/libunbound.so.8.1.5
80+
obj:/usr/local/lib/libunbound.so.8.1.5
81+
obj:/usr/local/lib/libunbound.so.8.1.5
82+
obj:/usr/local/lib/libunbound.so.8.1.5
83+
obj:/usr/local/lib/libunbound.so.8.1.5
84+
obj:/usr/local/lib/libunbound.so.8.1.5
85+
fun:_getdns_submit_netreq
86+
}
87+
{
88+
<insert_a_suppression_name_here>
89+
Memcheck:Cond
90+
obj:/lib/libc.so.7
91+
obj:*
92+
obj:/usr/local/lib/libunbound.so.8.1.5
93+
obj:/usr/local/lib/libunbound.so.8.1.5
94+
obj:/usr/local/lib/libunbound.so.8.1.5
95+
obj:/usr/local/lib/libunbound.so.8.1.5
96+
obj:/usr/local/lib/libunbound.so.8.1.5
97+
obj:/usr/local/lib/libunbound.so.8.1.5
98+
obj:/usr/local/lib/libunbound.so.8.1.5
99+
obj:/usr/local/lib/libunbound.so.8.1.5
100+
obj:/usr/local/lib/libunbound.so.8.1.5
101+
obj:/usr/local/lib/libunbound.so.8.1.5
102+
}

src/test/tpkg/225-stub-only-valgrind-checks.tpkg/225-stub-only-valgrind-checks.test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
# use .tpkg.var.test for in test variable passing
55
[ -f .tpkg.var.test ] && source .tpkg.var.test
66

7-
cat >queries <<EOT
8-
NS .
9-
-A getdnsapi.net
10-
qwerlkjhasdfpuiqwyerm.1234kjhrqwersv.com
11-
-G TXT bogus.nlnetlabs.nl
12-
-H 8.8.8.8
13-
-H 2a04:b900:0:100::37
14-
-A _acme-challenge.getdnsapi.net
15-
EOT
7+
## To add suppressions:
8+
##
9+
#
10+
# valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes --gen-suppressions=all "${GETDNS_STUB_QUERY}" -F "${TPKG_NAME}.queries" +dnssec_return_validation_chain
11+
# ./${TPKG_NAME}.parse_valgrind_suppressions.sh < valgrind.log > new_supps
12+
# cat ${TPKG_NAME}.supp new_supps > tmp_supps
13+
# mv tmp_supps ${TPKG_NAME}.supp
14+
#
15+
1616
(
17-
if ! valgrind -v --log-file=valgrind.log --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_STUB_QUERY}" -F queries -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
17+
if ! valgrind -v --log-file=valgrind.log --suppressions="${TPKG_NAME}.supp" --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_STUB_QUERY}" -F "${TPKG_NAME}.queries" +dnssec_return_validation_chain
1818
then
1919
exit 1
2020
fi

src/test/tpkg/275-server-capabilities.tpkg/275-server-capabilities.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ int main(int argc, char **argv)
9292
uint32_t port1 = 18000;
9393
uint32_t port2 = 18000;
9494
getdns_return_t r;
95-
char listenliststr[1024];
96-
char listendictstr[1024];
95+
char listenliststr[1024] = "";
96+
char listendictstr[1024] = "";
9797

9898
if (argc != 2) {
9999
fprintf(stderr, "usage: %s <localhost ipv4>\n", argv[0]);

0 commit comments

Comments
 (0)