diff options
author | Tom Gundersen <teg@jklm.no> | 2015-05-25 23:10:26 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-05-25 23:10:26 +0200 |
commit | e136009df20f02e8f4e1dc179da58e3fbd93342c (patch) | |
tree | 8a9c690d6cc3d691019465d9d6141f2fa85b99d6 /src | |
parent | cc9fce65544117f9c5e02daed6fb445c10127e37 (diff) | |
download | systemd-e136009df20f02e8f4e1dc179da58e3fbd93342c.tar.gz |
test: hostname - test that hostname is truly initialized
Fixes CID CID 1299638 (use after free).
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test-util.c | 7 |
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; |