updater: Use android::base::ParseInt() to parse integers.

Change-Id: Ic769eafc8d9535b1d517d3dcbd398c3fd65cddd9
diff --git a/updater/install.cpp b/updater/install.cpp
index 68c9902..97e3905 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -34,6 +34,7 @@
 #include <linux/xattr.h>
 #include <inttypes.h>
 
+#include <base/parseint.h>
 #include <base/strings.h>
 #include <base/stringprintf.h>
 
@@ -474,7 +475,8 @@
     }
 
     double frac = strtod(frac_str, NULL);
-    int sec = strtol(sec_str, NULL, 10);
+    int sec;
+    android::base::ParseInt(sec_str, &sec);
 
     UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
     fprintf(ui->cmd_pipe, "progress %f %d\n", frac, sec);
@@ -1145,12 +1147,11 @@
         return NULL;
     }
 
-    char* endptr;
-    size_t bytes = strtol(bytes_str, &endptr, 10);
-    if (bytes == 0 && endptr == bytes_str) {
+    size_t bytes;
+    if (!android::base::ParseUint(bytes_str, &bytes)) {
         ErrorAbort(state, "%s(): can't parse \"%s\" as byte count\n\n", name, bytes_str);
         free(bytes_str);
-        return NULL;
+        return nullptr;
     }
 
     return StringValue(strdup(CacheSizeCheck(bytes) ? "" : "t"));
@@ -1174,16 +1175,14 @@
         return NULL;
     }
 
-    char* endptr;
-    size_t target_size = strtol(target_size_str, &endptr, 10);
-    if (target_size == 0 && endptr == target_size_str) {
-        ErrorAbort(state, "%s(): can't parse \"%s\" as byte count",
-                   name, target_size_str);
+    size_t target_size;
+    if (!android::base::ParseUint(target_size_str, &target_size)) {
+        ErrorAbort(state, "%s(): can't parse \"%s\" as byte count", name, target_size_str);
         free(source_filename);
         free(target_filename);
         free(target_sha1);
         free(target_size_str);
-        return NULL;
+        return nullptr;
     }
 
     int patchcount = (argc-4) / 2;
@@ -1523,7 +1522,8 @@
     char* len_str;
     if (ReadArgs(state, argv, 2, &filename, &len_str) < 0) return NULL;
 
-    size_t len = strtoull(len_str, NULL, 0);
+    size_t len;
+    android::base::ParseUint(len_str, &len);
     int fd = open(filename, O_WRONLY, 0644);
     int success = wipe_block_device(fd, len);