Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023.8-3 coverity minor fixes #3263

Closed
wants to merge 10 commits into from
6 changes: 5 additions & 1 deletion src/libostree/ostree-checksum-input-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ ostree_checksum_input_stream_read (GInputStream *stream, void *buffer, gsize cou

res = g_input_stream_read (fself->base_stream, buffer, count, cancellable, error);
if (res > 0)
g_checksum_update (self->priv->checksum, buffer, res);
{
guchar *char_buffer = (guchar *)buffer;
char_buffer[res] = '\0';
g_checksum_update (self->priv->checksum, (const guchar *)char_buffer, res);
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved
}

return res;
}
3 changes: 2 additions & 1 deletion src/libostree/ostree-mutable-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ ostree_mutable_tree_ensure_parent_dirs (OstreeMutableTree *self, GPtrArray *spli
invalidate_contents_checksum (subdir);
next = ostree_mutable_tree_new ();
ostree_mutable_tree_set_metadata_checksum (next, metadata_checksum);
insert_child_mtree (subdir, g_strdup (name), next);
g_autofree char *name_copy = g_strdup (name);
insert_child_mtree (subdir, name_copy, next);
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved
}

subdir = next;
Expand Down
1 change: 1 addition & 0 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ _try_clone_from_payload_link (OstreeRepo *self, OstreeRepo *dest_repo, const cha
if (size < OSTREE_SHA256_STRING_LEN + _OSTREE_PAYLOAD_LINK_PREFIX_LEN)
return glnx_throw (error, "invalid data size for %s", loose_path_buf);

target_buf[size] = '\0';
sprintf (target_checksum, "%.2s%.62s", target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN,
target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN + 3);
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
2 changes: 1 addition & 1 deletion src/libostree/ostree-repo-libarchive.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ aic_get_final_path (OstreeRepoArchiveImportContext *ctx, const char *path, GErro
char *ret = ctx->opts->translate_pathname (ctx->repo, &stbuf, path,
ctx->opts->translate_pathname_user_data);
if (ret)
return ret;
return g_strdup (ret);
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved
/* Fall through */
}
else if (ctx->opts->use_ostree_convention)
Expand Down
2 changes: 1 addition & 1 deletion src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -5952,7 +5952,7 @@ find_remotes_cb (GObject *obj, GAsyncResult *async_result, gpointer user_data)
{
g_debug ("%s: Omitting remote ‘%s’ from results as none of its refs are new enough.",
G_STRFUNC, result->remote->name);
ostree_repo_finder_result_free (g_steal_pointer (&g_ptr_array_index (results, i)));
ostree_repo_finder_result_free (g_ptr_array_index (results, i));
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libostree/ostree-repo-static-delta-compilation.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ try_content_rollsum (OstreeRepo *repo, DeltaOpts opts, const char *from, const c
(unsigned long long)matches->match_size);
}

ContentRollsum *ret_rollsum = g_new0 (ContentRollsum, 1);
g_autofree ContentRollsum *ret_rollsum = g_new0 (ContentRollsum, 1);
ret_rollsum->from_checksum = g_strdup (from);
ret_rollsum->matches = g_steal_pointer (&matches);
ot_transfer_out_value (out_rollsum, &ret_rollsum);
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
3 changes: 2 additions & 1 deletion src/libostree/ostree-repo-static-delta-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ ostree_repo_static_delta_execute_offline_with_signature (OstreeRepo *self, GFile
return glnx_throw_errno_prefix (error, "openat(O_DIRECTORY)");
else
{
g_autofree char *dir = dirname (g_strdup (dir_or_file_path));
g_autofree char *dir_or_file_path_copy = g_strdup (dir_or_file_path);
g_autofree char *dir = dirname (dir_or_file_path_copy);
lukewarmtemp marked this conversation as resolved.
Show resolved Hide resolved
basename = g_path_get_basename (dir_or_file_path);

if (!glnx_opendirat (AT_FDCWD, dir, TRUE, &dfd, error))
Expand Down