summaryrefslogtreecommitdiff
path: root/verity
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2015-03-18 10:58:27 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-18 10:58:27 +0000
commitc1c760bc3fbcc26b5200ecd3034f75ef5138829b (patch)
treeb2795baaa10a59572ae083b9f877072d7b6d61e8 /verity
parent1934ff99d61531712f1d9b39fff90f32f5589de9 (diff)
parentc87b4134e5504bec39c4ed36b97863d7ed51dee1 (diff)
downloadextras-c1c760bc3fbcc26b5200ecd3034f75ef5138829b.tar.gz
am c87b4134: Merge "Add 64 bit support to verity build."
* commit 'c87b4134e5504bec39c4ed36b97863d7ed51dee1': Add 64 bit support to verity build.
Diffstat (limited to 'verity')
-rw-r--r--verity/build_verity_tree.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/verity/build_verity_tree.cpp b/verity/build_verity_tree.cpp
index 1281c6a4..5e04ce50 100644
--- a/verity/build_verity_tree.cpp
+++ b/verity/build_verity_tree.cpp
@@ -9,6 +9,7 @@
#include <getopt.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -126,7 +127,7 @@ int main(int argc, char **argv)
size_t salt_size = 0;
bool sparse = false;
size_t block_size = 4096;
- size_t calculate_size = 0;
+ uint64_t calculate_size = 0;
while (1) {
const static struct option long_options[] = {
@@ -135,6 +136,7 @@ int main(int argc, char **argv)
{"help", no_argument, 0, 'h'},
{"sparse", no_argument, 0, 'S'},
{"verity-size", required_argument, 0, 's'},
+ {NULL, 0, 0, 0}
};
int c = getopt_long(argc, argv, "a:A:hSs:", long_options, NULL);
if (c < 0) {
@@ -171,8 +173,19 @@ int main(int argc, char **argv)
case 'S':
sparse = true;
break;
- case 's':
- calculate_size = strtoul(optarg, NULL, 0);
+ case 's': {
+ char* endptr;
+ errno = 0;
+ unsigned long long int inSize = strtoull(optarg, &endptr, 0);
+ if (optarg[0] == '\0' || *endptr != '\0' ||
+ (errno == ERANGE && inSize == ULLONG_MAX)) {
+ FATAL("invalid value of verity-size\n");
+ }
+ if (inSize > UINT64_MAX) {
+ FATAL("invalid value of verity-size\n");
+ }
+ calculate_size = (uint64_t)inSize;
+ }
break;
case '?':
usage();
@@ -226,7 +239,7 @@ int main(int argc, char **argv)
verity_blocks += level_blocks;
} while (level_blocks > 1);
- printf("%zu\n", verity_blocks * block_size);
+ printf("%" PRIu64 "\n", (uint64_t)verity_blocks * block_size);
return 0;
}