summaryrefslogtreecommitdiff
path: root/verity
diff options
context:
space:
mode:
authorQin Ying <qin.ying@sonymobile.com>2014-10-14 11:53:23 +0900
committerHenrik Baard <henrik.baard@sonymobile.com>2015-03-06 07:37:52 +0100
commit88ea006e101703d0da66d9b43a7b2349da4db260 (patch)
tree30055b6d40186ab4c95fc8ab940b8ce4cd161adc /verity
parent7e1e079174f9c78e954d15c086acdbfba8d73e83 (diff)
downloadextras-88ea006e101703d0da66d9b43a7b2349da4db260.tar.gz
Add 64 bit support to verity build.
Now build verity only support 32bit environment, when the image size is bigger than 2^32 the verity image size calculation will be mistake. Change-Id: I41e5fe720c1269d6c06e23bfce5bc65226fb6e77
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;
}