summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2016-11-18 10:33:50 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2016-11-21 16:34:06 +0000
commit49b8a726221de7b9abf6c70bddadc0c21ff7b697 (patch)
tree0e0349bae0272e74485d01814b3b7f0b4a23c5f5
parenteb7ba645af8bc8332dcd5a73f682d46e8642a2ce (diff)
downloadostree-49b8a726221de7b9abf6c70bddadc0c21ff7b697.tar.gz
[ASAN] lib: Squash various leaks in library and commandline
The pull one is the most likely to affect users. Otherwise mostly just cleaning up `-fsanitize=address`. Closes: #587 Approved by: jlebon
-rw-r--r--src/libostree/ostree-metalink.c3
-rw-r--r--src/libostree/ostree-repo-libarchive.c5
-rw-r--r--src/libostree/ostree-repo-pull.c6
-rw-r--r--src/libostree/ostree-repo-static-delta-compilation-analysis.c2
-rw-r--r--src/libostree/ostree-repo-static-delta-core.c4
-rw-r--r--src/libostree/ostree-sepolicy.c4
-rw-r--r--src/libostree/ostree-sysroot-cleanup.c2
-rw-r--r--src/libostree/ostree-sysroot-upgrader.c1
-rw-r--r--src/ostree/ot-builtin-export.c6
-rw-r--r--src/ostree/ot-builtin-fsck.c2
-rw-r--r--src/ostree/ot-remote-builtin-add-cookie.c4
-rw-r--r--src/ostree/ot-remote-builtin-delete-cookie.c4
12 files changed, 30 insertions, 13 deletions
diff --git a/src/libostree/ostree-metalink.c b/src/libostree/ostree-metalink.c
index b850818d..ad3d5bf9 100644
--- a/src/libostree/ostree-metalink.c
+++ b/src/libostree/ostree-metalink.c
@@ -632,6 +632,9 @@ _ostree_metalink_request_sync (OstreeMetalink *self,
if (mainctx)
g_main_context_pop_thread_default (mainctx);
g_clear_object (&request.metalink);
+ g_clear_pointer (&request.verification_sha256, g_free);
+ g_clear_pointer (&request.verification_sha512, g_free);
+ g_clear_pointer (&request.last_metalink_error, g_free);
g_clear_pointer (&request.urls, g_ptr_array_unref);
g_clear_pointer (&request.parser, g_markup_parse_context_free);
return ret;
diff --git a/src/libostree/ostree-repo-libarchive.c b/src/libostree/ostree-repo-libarchive.c
index 3a58d106..02a1180a 100644
--- a/src/libostree/ostree-repo-libarchive.c
+++ b/src/libostree/ostree-repo-libarchive.c
@@ -943,7 +943,10 @@ ostree_repo_write_archive_to_mtree (OstreeRepo *self,
ret = TRUE;
out:
if (a)
- (void)archive_read_close (a);
+ {
+ (void)archive_read_close (a);
+ (void)archive_read_free (a);
+ }
return ret;
#else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 8c18052f..9e960792 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -1982,7 +1982,7 @@ _ostree_repo_remote_new_fetcher (OstreeRepo *self,
g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt",
remote_name);
- jar_path = g_build_filename (g_file_get_path (self->repodir), cookie_file,
+ jar_path = g_build_filename (gs_file_get_path_cached (self->repodir), cookie_file,
NULL);
if (g_file_test(jar_path, G_FILE_TEST_IS_REGULAR))
@@ -2061,7 +2061,7 @@ fetch_mirrorlist (OstreeFetcher *fetcher,
GError **error)
{
gboolean ret = FALSE;
- char **lines = NULL;
+ g_auto(GStrv) lines = NULL;
g_autofree char *contents = NULL;
SoupURI *mirrorlist = NULL;
g_autoptr(GPtrArray) ret_mirrorlist =
@@ -2367,7 +2367,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
const char *dir_to_pull = NULL;
g_autofree char **dirs_to_pull = NULL;
g_autofree char **refs_to_fetch = NULL;
- char **override_commit_ids = NULL;
+ g_autofree char **override_commit_ids = NULL;
GSource *update_timeout = NULL;
gboolean disable_static_deltas = FALSE;
gboolean require_static_deltas = FALSE;
diff --git a/src/libostree/ostree-repo-static-delta-compilation-analysis.c b/src/libostree/ostree-repo-static-delta-compilation-analysis.c
index c1990591..2b9b006f 100644
--- a/src/libostree/ostree-repo-static-delta-compilation-analysis.c
+++ b/src/libostree/ostree-repo-static-delta-compilation-analysis.c
@@ -243,7 +243,7 @@ _ostree_delta_compute_similar_objects (OstreeRepo *repo,
{
gboolean ret = FALSE;
g_autoptr(GHashTable) ret_modified_regfile_content =
- g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_ptr_array_unref);
+ g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_autoptr(GPtrArray) from_sizes = NULL;
g_autoptr(GPtrArray) to_sizes = NULL;
guint i, j;
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index 0b0d7067..133ab016 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -880,7 +880,9 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
OT_VARIANT_MAP_TRUSTED, &delta_superblock, error))
goto out;
- g_print ("%s\n", g_variant_print (delta_superblock, 1));
+ { g_autofree char *variant_string = g_variant_print (delta_superblock, 1);
+ g_print ("%s\n", variant_string);
+ }
g_print ("Delta: %s\n", delta_id);
{ const char *endianness_description;
diff --git a/src/libostree/ostree-sepolicy.c b/src/libostree/ostree-sepolicy.c
index 8e49428f..fa264704 100644
--- a/src/libostree/ostree-sepolicy.c
+++ b/src/libostree/ostree-sepolicy.c
@@ -258,7 +258,7 @@ initable_init (GInitable *initable,
g_autoptr(GFileInputStream) filein = NULL;
g_autoptr(GDataInputStream) datain = NULL;
gboolean enabled = FALSE;
- char *policytype = NULL;
+ g_autofree char *policytype = NULL;
const char *selinux_prefix = "SELINUX=";
const char *selinuxtype_prefix = "SELINUXTYPE=";
@@ -352,7 +352,7 @@ initable_init (GInitable *initable,
goto out;
}
- self->selinux_policy_name = g_strdup (policytype);
+ self->selinux_policy_name = g_steal_pointer (&policytype);
self->selinux_policy_root = g_object_ref (etc_selinux_dir);
}
diff --git a/src/libostree/ostree-sysroot-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c
index 862d8154..2a78d2ce 100644
--- a/src/libostree/ostree-sysroot-cleanup.c
+++ b/src/libostree/ostree-sysroot-cleanup.c
@@ -491,7 +491,7 @@ prune_repo (OstreeRepo *repo,
if (freed_space > 0)
{
- char *freed_space_str = g_format_size_full (freed_space, 0);
+ g_autofree char *freed_space_str = g_format_size_full (freed_space, 0);
g_print ("Freed objects: %s\n", freed_space_str);
}
diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c
index b0061c87..447bd82b 100644
--- a/src/libostree/ostree-sysroot-upgrader.c
+++ b/src/libostree/ostree-sysroot-upgrader.c
@@ -105,6 +105,7 @@ parse_refspec (OstreeSysrootUpgrader *self,
csum = g_key_file_get_string (self->origin, "origin", "override-commit", NULL);
if (csum != NULL && !ostree_validate_checksum_string (csum, error))
goto out;
+ g_clear_pointer (&self->override_csum, g_free);
self->override_csum = g_steal_pointer (&csum);
ret = TRUE;
diff --git a/src/ostree/ot-builtin-export.c b/src/ostree/ot-builtin-export.c
index 5b84d1ab..db4dbc31 100644
--- a/src/ostree/ot-builtin-export.c
+++ b/src/ostree/ot-builtin-export.c
@@ -67,7 +67,7 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
g_autoptr(GFile) subtree = NULL;
g_autofree char *commit = NULL;
g_autoptr(GVariant) commit_data = NULL;
- struct archive *a;
+ struct archive *a = NULL;
OstreeRepoExportArchiveOptions opts = { 0, };
context = g_option_context_new ("COMMIT - Stream COMMIT to stdout in tar format");
@@ -154,6 +154,10 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
ret = TRUE;
out:
+#ifdef HAVE_LIBARCHIVE
+ if (a)
+ archive_write_free (a);
+#endif
if (context)
g_option_context_free (context);
return ret;
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index 5afa435f..9809ad29 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -287,7 +287,7 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
if (opt_add_tombstones)
{
GError *local_error = NULL;
- const char *parent = ostree_commit_get_parent (commit);
+ g_autofree char *parent = ostree_commit_get_parent (commit);
if (parent)
{
g_autoptr(GVariant) parent_commit = NULL;
diff --git a/src/ostree/ot-remote-builtin-add-cookie.c b/src/ostree/ot-remote-builtin-add-cookie.c
index 439e7503..f1657bb8 100644
--- a/src/ostree/ot-remote-builtin-add-cookie.c
+++ b/src/ostree/ot-remote-builtin-add-cookie.c
@@ -68,7 +68,7 @@ ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable,
value = argv[5];
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
- jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
+ jar_path = g_build_filename (gs_file_get_path_cached (repo->repodir), cookie_file, NULL);
jar = soup_cookie_jar_text_new (jar_path, FALSE);
@@ -80,5 +80,7 @@ ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable,
/* jar takes ownership of cookie */
soup_cookie_jar_add_cookie (jar, cookie);
+ if (context)
+ g_option_context_free (context);
return TRUE;
}
diff --git a/src/ostree/ot-remote-builtin-delete-cookie.c b/src/ostree/ot-remote-builtin-delete-cookie.c
index 9f05a564..df65b277 100644
--- a/src/ostree/ot-remote-builtin-delete-cookie.c
+++ b/src/ostree/ot-remote-builtin-delete-cookie.c
@@ -67,7 +67,7 @@ ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellabl
cookie_name = argv[4];
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
- jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
+ jar_path = g_build_filename (gs_file_get_path_cached (repo->repodir), cookie_file, NULL);
jar = soup_cookie_jar_text_new (jar_path, FALSE);
cookies = soup_cookie_jar_all_cookies (jar);
@@ -92,5 +92,7 @@ ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellabl
if (!found)
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Cookie not found in jar");
+ if (context)
+ g_option_context_free (context);
return found;
}