am c87b4134: Merge "Add 64 bit support to verity build."

* commit 'c87b4134e5504bec39c4ed36b97863d7ed51dee1':
  Add 64 bit support to verity build.
diff --git a/verity/build_verity_tree.cpp b/verity/build_verity_tree.cpp
index 1281c6a..5e04ce5 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 @@
     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 @@
             {"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 @@
         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 @@
             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;
     }