summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-05-25 23:10:26 +0200
committerTom Gundersen <teg@jklm.no>2015-05-25 23:10:26 +0200
commite136009df20f02e8f4e1dc179da58e3fbd93342c (patch)
tree8a9c690d6cc3d691019465d9d6141f2fa85b99d6 /src/test/test-util.c
parentcc9fce65544117f9c5e02daed6fb445c10127e37 (diff)
test: hostname - test that hostname is truly initialized
Fixes CID CID 1299638 (use after free).
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r--src/test/test-util.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 36773c109d..41cbe81b3d 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -563,24 +563,31 @@ static void test_read_hostname_config(void) {
assert_se(read_hostname_config(path, &hostname) == 0);
assert_se(streq(hostname, "foo"));
free(hostname);
+ hostname = NULL;
/* with comment */
write_string_file(path, "# comment\nfoo");
assert_se(read_hostname_config(path, &hostname) == 0);
+ assert_se(hostname);
assert_se(streq(hostname, "foo"));
free(hostname);
+ hostname = NULL;
/* with comment and extra whitespace */
write_string_file(path, "# comment\n\n foo ");
assert_se(read_hostname_config(path, &hostname) == 0);
+ assert_se(hostname);
assert_se(streq(hostname, "foo"));
free(hostname);
+ hostname = NULL;
/* cleans up name */
write_string_file(path, "!foo/bar.com");
assert_se(read_hostname_config(path, &hostname) == 0);
+ assert_se(hostname);
assert_se(streq(hostname, "foobar.com"));
free(hostname);
+ hostname = NULL;
/* no value set */
hostname = (char*) 0x1234;