]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: hostname - test that hostname is truly initialized
authorTom Gundersen <teg@jklm.no>
Mon, 25 May 2015 21:10:26 +0000 (23:10 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 25 May 2015 21:10:26 +0000 (23:10 +0200)
Fixes CID CID 1299638 (use after free).

src/test/test-util.c

index 36773c109da2d367f8a1dc01120446cd2baceb4c..41cbe81b3db18a2bf70d9ab98284c380f41cd6f0 100644 (file)
@@ -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;