From: Tom Gundersen Date: Mon, 25 May 2015 21:10:26 +0000 (+0200) Subject: test: hostname - test that hostname is truly initialized X-Git-Tag: v221~281 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e136009df20f02e8f4e1dc179da58e3fbd93342c;p=thirdparty%2Fsystemd.git test: hostname - test that hostname is truly initialized Fixes CID CID 1299638 (use after free). --- diff --git a/src/test/test-util.c b/src/test/test-util.c index 36773c109da..41cbe81b3db 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;