summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathnerd314 <mathnerd314.gph+hs@gmail.com>2016-06-18 10:31:19 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2016-06-22 16:10:01 +0000
commit4cb77c51db5096eea19b82c30f7bb09434a620e0 (patch)
treea824c332644f76663ccf8b210e2636c158582582 /src
parent91ccaff197ddefebe4965108ed19735bcbb6bfd3 (diff)
downloadostree-4cb77c51db5096eea19b82c30f7bb09434a620e0.tar.gz
core: Use OSTREE_SHA256_STRING_LEN instead of 64
Closes: #359 Approved by: cgwalters
Diffstat (limited to 'src')
-rw-r--r--src/libostree/ostree-core.c8
-rw-r--r--src/libostree/ostree-core.h12
-rw-r--r--src/libostree/ostree-repo-checkout.c2
-rw-r--r--src/libostree/ostree-repo-commit.c2
-rw-r--r--src/libostree/ostree-repo-file.c12
-rw-r--r--src/libostree/ostree-repo-private.h2
-rw-r--r--src/libostree/ostree-repo-pull.c2
-rw-r--r--src/libostree/ostree-repo-refs.c6
-rw-r--r--src/libostree/ostree-repo-static-delta-core.c6
-rw-r--r--src/libostree/ostree-repo-static-delta-processing.c4
-rw-r--r--src/libostree/ostree-repo-traverse.c4
-rw-r--r--src/libostree/ostree-repo.c2
-rw-r--r--src/libostree/ostree-repo.h2
-rw-r--r--src/ostree/ot-dump.c2
14 files changed, 39 insertions, 27 deletions
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 1a3740f8..4e3816f5 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -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);
diff --git a/src/libostree/ostree-core.h b/src/libostree/ostree-core.h
index 4a0e60e9..b8675672 100644
--- a/src/libostree/ostree-core.h
+++ b/src/libostree/ostree-core.h
@@ -51,9 +51,21 @@ 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
* @OSTREE_OBJECT_TYPE_DIR_TREE: List of children (trees or files), and metadata
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
index 59c8517a..a6d69c42 100644
--- a/src/libostree/ostree-repo-checkout.c
+++ b/src/libostree/ostree-repo-checkout.c
@@ -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);
}
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index 0d45dd47..3670dea7 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -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);
diff --git a/src/libostree/ostree-repo-file.c b/src/libostree/ostree-repo-file.c
index 396820da..a88e5363 100644
--- a/src/libostree/ostree-repo-file.c
+++ b/src/libostree/ostree-repo-file.c
@@ -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))
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
index f330d169..52dbfdd5 100644
--- a/src/libostree/ostree-repo-private.h
+++ b/src/libostree/ostree-repo-private.h
@@ -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-"
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 53847340..672da831 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -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;
diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c
index d9af2256..1eb50e0c 100644
--- a/src/libostree/ostree-repo-refs.c
+++ b/src/libostree/ostree-repo-refs.c
@@ -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);
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index d4f8a573..6253a45f 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -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;
diff --git a/src/libostree/ostree-repo-static-delta-processing.c b/src/libostree/ostree-repo-static-delta-processing.c
index 681d426f..871ab7bd 100644
--- a/src/libostree/ostree-repo-static-delta-processing.c
+++ b/src/libostree/ostree-repo-static-delta-processing.c
@@ -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,
diff --git a/src/libostree/ostree-repo-traverse.c b/src/libostree/ostree-repo-traverse.c
index 503ab329..4cc05e2e 100644
--- a/src/libostree/ostree-repo-traverse.c
+++ b/src/libostree/ostree-repo-traverse.c
@@ -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];
};
/**
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 843a6489..c6520a80 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -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)
diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h
index ce280ee6..c023b4d2 100644
--- a/src/libostree/ostree-repo.h
+++ b/src/libostree/ostree-repo.h
@@ -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;
diff --git a/src/ostree/ot-dump.c b/src/ostree/ot-dump.c
index 48b087af..4fc84cbd 100644
--- a/src/ostree/ot-dump.c
+++ b/src/ostree/ot-dump.c
@@ -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);