diff options
author | Sami Tolvanen <samitolvanen@google.com> | 2015-03-18 09:02:13 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-18 09:02:13 +0000 |
commit | c87b4134e5504bec39c4ed36b97863d7ed51dee1 (patch) | |
tree | 4586f1018bec3393bcbc2be24b04dbe4b1925b06 /verity | |
parent | 57526dafbf62f003d74fc48084cc252843f061f7 (diff) | |
parent | 88ea006e101703d0da66d9b43a7b2349da4db260 (diff) | |
download | extras-c87b4134e5504bec39c4ed36b97863d7ed51dee1.tar.gz |
Merge "Add 64 bit support to verity build."
Diffstat (limited to 'verity')
-rw-r--r-- | verity/build_verity_tree.cpp | 21 |
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; } |