add checksum parameters to got_inflate functions which did not provide them yet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
diff --git a/lib/got_lib_inflate.h b/lib/got_lib_inflate.h
index 0ccf42c..ad8c052 100644
--- a/lib/got_lib_inflate.h
+++ b/lib/got_lib_inflate.h
@@ -46,14 +46,16 @@ const struct got_error *got_inflate_read_mmap(struct got_inflate_buf *,
uint8_t *, size_t, size_t, size_t *, size_t *);
void got_inflate_end(struct got_inflate_buf *);
const struct got_error *got_inflate_to_mem(uint8_t **, size_t *, size_t *,
- FILE *);
+ struct got_inflate_checksum *, FILE *);
const struct got_error *got_inflate_to_mem_fd(uint8_t **, size_t *, size_t *,
struct got_inflate_checksum *, size_t, int);
const struct got_error *got_inflate_to_mem_mmap(uint8_t **, size_t *, size_t *,
struct got_inflate_checksum *, uint8_t *, size_t, size_t);
-const struct got_error *got_inflate_to_file(size_t *, FILE *, FILE *);
+const struct got_error *got_inflate_to_file(size_t *, FILE *,
+ struct got_inflate_checksum *, FILE *);
const struct got_error *got_inflate_to_file_fd(size_t *, size_t *,
struct got_inflate_checksum *, int, FILE *);
-const struct got_error *got_inflate_to_fd(size_t *, FILE *, int);
+const struct got_error *got_inflate_to_fd(size_t *, FILE *,
+ struct got_inflate_checksum *, int);
const struct got_error *got_inflate_to_file_mmap(size_t *, size_t *,
struct got_inflate_checksum *, uint8_t *, size_t, size_t, FILE *);
diff --git a/lib/inflate.c b/lib/inflate.c
index 1197bbb..aa993fb 100644
--- a/lib/inflate.c
+++ b/lib/inflate.c
@@ -262,7 +262,7 @@ got_inflate_end(struct got_inflate_buf *zb)
const struct got_error *
got_inflate_to_mem(uint8_t **outbuf, size_t *outlen,
- size_t *consumed_total, FILE *f)
+ size_t *consumed_total, struct got_inflate_checksum *csum, FILE *f)
{
const struct got_error *err;
size_t avail, consumed;
@@ -274,9 +274,9 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen,
*outbuf = malloc(GOT_INFLATE_BUFSIZE);
if (*outbuf == NULL)
return got_error_from_errno("malloc");
- err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE, NULL);
+ err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE, csum);
} else
- err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE, NULL);
+ err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE, csum);
if (err)
return err;
@@ -437,13 +437,14 @@ done:
}
const struct got_error *
-got_inflate_to_fd(size_t *outlen, FILE *infile, int outfd)
+got_inflate_to_fd(size_t *outlen, FILE *infile,
+ struct got_inflate_checksum *csum, int outfd)
{
const struct got_error *err = NULL;
size_t avail;
struct got_inflate_buf zb;
- err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE, NULL);
+ err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE, csum);
if (err)
goto done;
@@ -474,13 +475,14 @@ done:
}
const struct got_error *
-got_inflate_to_file(size_t *outlen, FILE *infile, FILE *outfile)
+got_inflate_to_file(size_t *outlen, FILE *infile,
+ struct got_inflate_checksum *csum, FILE *outfile)
{
const struct got_error *err;
size_t avail;
struct got_inflate_buf zb;
- err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE, NULL);
+ err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE, csum);
if (err)
goto done;
diff --git a/libexec/got-read-blob/got-read-blob.c b/libexec/got-read-blob/got-read-blob.c
index 092a8f9..59f45b5 100644
--- a/libexec/got-read-blob/got-read-blob.c
+++ b/libexec/got-read-blob/got-read-blob.c
@@ -146,11 +146,11 @@ main(int argc, char *argv[])
if (obj->size + obj->hdrlen <=
GOT_PRIVSEP_INLINE_BLOB_DATA_MAX) {
- err = got_inflate_to_mem(&buf, &size, NULL, f);
+ err = got_inflate_to_mem(&buf, &size, NULL, NULL, f);
if (err)
goto done;
} else {
- err = got_inflate_to_fd(&size, f, imsg_outfd.fd);
+ err = got_inflate_to_fd(&size, f, NULL, imsg_outfd.fd);
if (err)
goto done;
}
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index 41be1ea..93245b3 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -55,7 +55,7 @@ read_commit_object(struct got_commit_object **commit, FILE *f)
size_t len;
uint8_t *p;
- err = got_inflate_to_mem(&p, &len, NULL, f);
+ err = got_inflate_to_mem(&p, &len, NULL, NULL, f);
if (err)
return err;
diff --git a/libexec/got-read-object/got-read-object.c b/libexec/got-read-object/got-read-object.c
index 8cb2bc3..d91d50b 100644
--- a/libexec/got-read-object/got-read-object.c
+++ b/libexec/got-read-object/got-read-object.c
@@ -78,9 +78,9 @@ send_raw_obj(struct imsgbuf *ibuf, struct got_object *obj, int fd, int outfd)
}
if (obj->size + obj->hdrlen <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX)
- err = got_inflate_to_mem(&data, &len, &consumed, f);
+ err = got_inflate_to_mem(&data, &len, &consumed, NULL, f);
else
- err = got_inflate_to_fd(&len, f, outfd);
+ err = got_inflate_to_fd(&len, f, NULL, outfd);
if (err)
goto done;
diff --git a/libexec/got-read-tag/got-read-tag.c b/libexec/got-read-tag/got-read-tag.c
index 2ee8df0..f3ce48d 100644
--- a/libexec/got-read-tag/got-read-tag.c
+++ b/libexec/got-read-tag/got-read-tag.c
@@ -55,7 +55,7 @@ read_tag_object(struct got_tag_object **tag, FILE *f)
size_t len;
uint8_t *p;
- err = got_inflate_to_mem(&p, &len, NULL, f);
+ err = got_inflate_to_mem(&p, &len, NULL, NULL, f);
if (err)
return err;
diff --git a/libexec/got-read-tree/got-read-tree.c b/libexec/got-read-tree/got-read-tree.c
index 03b252f..aab6f58 100644
--- a/libexec/got-read-tree/got-read-tree.c
+++ b/libexec/got-read-tree/got-read-tree.c
@@ -56,7 +56,7 @@ read_tree_object(struct got_pathlist_head *entries, int *nentries,
struct got_object *obj;
size_t len;
- err = got_inflate_to_mem(p, &len, NULL, f);
+ err = got_inflate_to_mem(p, &len, NULL, NULL, f);
if (err)
return err;