core: Use OSTREE_SHA256_STRING_LEN instead of 64
Closes: #359 Approved by: cgwalters
This commit is contained in:
parent
91ccaff197
commit
4cb77c51db
|
|
@ -1269,7 +1269,7 @@ ostree_checksum_to_bytes_v (const char *checksum)
|
|||
/**
|
||||
* ostree_checksum_inplace_from_bytes: (skip)
|
||||
* @csum: (array fixed-size=32): An binary checksum of length 32
|
||||
* @buf: Output location, must be at least 65 bytes in length
|
||||
* @buf: Output location, must be at least OSTREE_SHA256_STRING_LEN+1 bytes in length
|
||||
*
|
||||
* Overwrite the contents of @buf with stringified version of @csum.
|
||||
*/
|
||||
|
|
@ -1340,7 +1340,7 @@ ostree_checksum_b64_inplace_from_bytes (const guchar *csum,
|
|||
char *
|
||||
ostree_checksum_from_bytes (const guchar *csum)
|
||||
{
|
||||
char *ret = g_malloc (65);
|
||||
char *ret = g_malloc (OSTREE_SHA256_STRING_LEN+1);
|
||||
ostree_checksum_inplace_from_bytes (csum, ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1484,7 +1484,7 @@ _ostree_get_relative_object_path (const char *checksum,
|
|||
{
|
||||
GString *path;
|
||||
|
||||
g_assert (strlen (checksum) == 64);
|
||||
g_assert (strlen (checksum) == OSTREE_SHA256_STRING_LEN);
|
||||
|
||||
path = g_string_new ("objects/");
|
||||
|
||||
|
|
@ -1759,7 +1759,7 @@ ostree_validate_structureof_checksum_string (const char *checksum,
|
|||
int i = 0;
|
||||
size_t len = strlen (checksum);
|
||||
|
||||
if (len != 64)
|
||||
if (len != OSTREE_SHA256_STRING_LEN)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid rev '%s'", checksum);
|
||||
|
|
|
|||
|
|
@ -51,8 +51,20 @@ G_BEGIN_DECLS
|
|||
*/
|
||||
#define OSTREE_MAX_RECURSION (256)
|
||||
|
||||
/**
|
||||
* OSTREE_SHA256_DIGEST_LEN:
|
||||
*
|
||||
* Length of a sha256 digest when expressed as raw bytes
|
||||
*/
|
||||
#define OSTREE_SHA256_DIGEST_LEN (32)
|
||||
|
||||
/**
|
||||
* OSTREE_SHA256_STRING_LEN:
|
||||
*
|
||||
* Length of a sha256 digest when expressed as a hexadecimal string
|
||||
*/
|
||||
#define OSTREE_SHA256_STRING_LEN (64)
|
||||
|
||||
/**
|
||||
* OstreeObjectType:
|
||||
* @OSTREE_OBJECT_TYPE_FILE: Content; regular file, symbolic link
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ checkout_one_file_at (OstreeRepo *repo,
|
|||
key = g_new (OstreeDevIno, 1);
|
||||
key->dev = stbuf.st_dev;
|
||||
key->ino = stbuf.st_ino;
|
||||
memcpy (key->checksum, checksum, 65);
|
||||
memcpy (key->checksum, checksum, OSTREE_SHA256_STRING_LEN+1);
|
||||
|
||||
g_hash_table_add ((GHashTable*)options->devino_to_csum_cache, key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2937,7 +2937,7 @@ ostree_repo_write_mtree (OstreeRepo *self,
|
|||
g_autoptr(GHashTable) dir_contents_checksums = NULL;
|
||||
g_autoptr(GVariant) serialized_tree = NULL;
|
||||
g_autofree guchar *contents_csum = NULL;
|
||||
char contents_checksum_buf[65];
|
||||
char contents_checksum_buf[OSTREE_SHA256_STRING_LEN+1];
|
||||
|
||||
dir_contents_checksums = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free, (GDestroyNotify)g_free);
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ _ostree_repo_file_new_root (OstreeRepo *repo,
|
|||
|
||||
g_return_val_if_fail (repo != NULL, NULL);
|
||||
g_return_val_if_fail (contents_checksum != NULL, NULL);
|
||||
g_return_val_if_fail (strlen (contents_checksum) == 64, NULL);
|
||||
g_return_val_if_fail (strlen (contents_checksum) == OSTREE_SHA256_STRING_LEN, NULL);
|
||||
g_return_val_if_fail (metadata_checksum != NULL, NULL);
|
||||
g_return_val_if_fail (strlen (metadata_checksum) == 64, NULL);
|
||||
g_return_val_if_fail (strlen (metadata_checksum) == OSTREE_SHA256_STRING_LEN, NULL);
|
||||
|
||||
self = g_object_new (OSTREE_TYPE_REPO_FILE, NULL);
|
||||
self->repo = g_object_ref (repo);
|
||||
|
|
@ -152,12 +152,12 @@ _ostree_repo_file_new_for_commit (OstreeRepo *repo,
|
|||
g_autoptr(GVariant) commit_v = NULL;
|
||||
g_autoptr(GVariant) tree_contents_csum_v = NULL;
|
||||
g_autoptr(GVariant) tree_metadata_csum_v = NULL;
|
||||
char tree_contents_csum[65];
|
||||
char tree_metadata_csum[65];
|
||||
char tree_contents_csum[OSTREE_SHA256_STRING_LEN + 1];
|
||||
char tree_metadata_csum[OSTREE_SHA256_STRING_LEN + 1];
|
||||
|
||||
g_return_val_if_fail (repo != NULL, NULL);
|
||||
g_return_val_if_fail (commit != NULL, NULL);
|
||||
g_return_val_if_fail (strlen (commit) == 64, NULL);
|
||||
g_return_val_if_fail (strlen (commit) == OSTREE_SHA256_STRING_LEN, NULL);
|
||||
|
||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
|
||||
commit, &commit_v, error))
|
||||
|
|
@ -807,7 +807,7 @@ ostree_repo_file_tree_query_child (OstreeRepoFile *self,
|
|||
g_autoptr(GVariant) dirs_variant = NULL;
|
||||
g_autoptr(GVariant) content_csum_v = NULL;
|
||||
g_autoptr(GVariant) meta_csum_v = NULL;
|
||||
char tmp_checksum[65];
|
||||
char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
GFileAttributeMatcher *matcher = NULL;
|
||||
|
||||
if (!ostree_repo_file_ensure_resolved (self, error))
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ struct OstreeRepo {
|
|||
typedef struct {
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
char checksum[65];
|
||||
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
} OstreeDevIno;
|
||||
|
||||
#define OSTREE_REPO_TMPDIR_STAGING "staging-"
|
||||
|
|
|
|||
|
|
@ -1096,7 +1096,7 @@ scan_commit_object (OtPullData *pull_data,
|
|||
}
|
||||
else if (parent_csum_bytes != NULL && depth > 0)
|
||||
{
|
||||
char parent_checksum[65];
|
||||
char parent_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
gpointer parent_depthp;
|
||||
int parent_depth;
|
||||
|
||||
|
|
|
|||
|
|
@ -341,10 +341,10 @@ ostree_repo_resolve_partial_checksum (OstreeRepo *self,
|
|||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
/* If the input is longer than 64 chars or contains non-hex chars,
|
||||
/* If the input is longer than OSTREE_SHA256_STRING_LEN chars or contains non-hex chars,
|
||||
don't bother looking for it as an object */
|
||||
off = strspn (refspec, hexchars);
|
||||
if (off > 64 || refspec[off] != '\0')
|
||||
if (off > OSTREE_SHA256_STRING_LEN || refspec[off] != '\0')
|
||||
return TRUE;
|
||||
|
||||
/* this looks through all objects and adds them to the ref_list if:
|
||||
|
|
@ -740,7 +740,7 @@ ostree_repo_remote_list_refs (OstreeRepo *self,
|
|||
{
|
||||
const char *ref_name = NULL;
|
||||
g_autoptr(GVariant) csum_v = NULL;
|
||||
char tmp_checksum[65];
|
||||
char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
|
||||
g_variant_get_child (child, 0, "&s", &ref_name);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ ostree_repo_list_static_delta_names (OstreeRepo *self,
|
|||
{
|
||||
g_autofree char *buf = g_strconcat (name1, name2, NULL);
|
||||
GString *out = g_string_new ("");
|
||||
char checksum[65];
|
||||
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
guchar csum[OSTREE_SHA256_DIGEST_LEN];
|
||||
const char *dash = strchr (buf, '-');
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ _ostree_repo_static_delta_part_have_all_objects (OstreeRepo *repo,
|
|||
{
|
||||
guint8 objtype = *checksums_data;
|
||||
const guint8 *csum = checksums_data + 1;
|
||||
char tmp_checksum[65];
|
||||
char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
|
||||
if (G_UNLIKELY(!ostree_validate_structureof_objtype (objtype, error)))
|
||||
goto out;
|
||||
|
|
@ -354,7 +354,7 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
|||
guint64 size;
|
||||
guint64 usize;
|
||||
const guchar *csum;
|
||||
char checksum[65];
|
||||
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
gboolean have_all;
|
||||
g_autoptr(GInputStream) part_in = NULL;
|
||||
g_autoptr(GBytes) delta_data = NULL;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ typedef struct {
|
|||
OstreeRepoContentBareCommit barecommitstate;
|
||||
guint64 content_size;
|
||||
GOutputStream *content_out;
|
||||
char checksum[65];
|
||||
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
char *read_source_object;
|
||||
int read_source_fd;
|
||||
gboolean have_obj;
|
||||
|
|
@ -78,7 +78,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
StaticDeltaExecutionState *state;
|
||||
char checksum[65];
|
||||
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||
} StaticDeltaContentWrite;
|
||||
|
||||
typedef gboolean (*DispatchOpFunc) (OstreeRepo *repo,
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ struct _OstreeRepoRealCommitTraverseIter {
|
|||
const char *name;
|
||||
OstreeRepoCommitIterResult state;
|
||||
guint idx;
|
||||
char checksum_content[65];
|
||||
char checksum_meta[65];
|
||||
char checksum_content[OSTREE_SHA256_STRING_LEN+1];
|
||||
char checksum_meta[OSTREE_SHA256_STRING_LEN+1];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2445,7 +2445,7 @@ list_loose_objects_at (OstreeRepo *self,
|
|||
const char *name = dent->d_name;
|
||||
const char *dot;
|
||||
OstreeObjectType objtype;
|
||||
char buf[65];
|
||||
char buf[OSTREE_SHA256_STRING_LEN+1];
|
||||
|
||||
if (strcmp (name, ".") == 0 ||
|
||||
strcmp (name, "..") == 0)
|
||||
|
|
|
|||
|
|
@ -866,7 +866,7 @@ gboolean ostree_repo_traverse_commit_union (OstreeRepo *repo,
|
|||
struct _OstreeRepoCommitTraverseIter {
|
||||
gboolean initialized;
|
||||
gpointer dummy[10];
|
||||
char dummy_checksum_data[65*2];
|
||||
char dummy_checksum_data[(OSTREE_SHA256_STRING_LEN+1)*2];
|
||||
};
|
||||
|
||||
typedef struct _OstreeRepoCommitTraverseIter OstreeRepoCommitTraverseIter;
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ dump_summary_ref (const char *ref_name,
|
|||
csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, &csum_error);
|
||||
if (csum_error == NULL)
|
||||
{
|
||||
char csum[65];
|
||||
char csum[OSTREE_SHA256_STRING_LEN+1];
|
||||
|
||||
ostree_checksum_inplace_from_bytes (csum_bytes, csum);
|
||||
g_print (" %s\n", csum);
|
||||
|
|
|
|||
Loading…
Reference in New Issue