update_engine: remove size_t in FEC write path

offset is calculated as a product of rs_n and some other size_t
variables. These variables are 32 bits on 32 bit platforms. We should
avoid usage of size_t when calculating storage bound values.

Bug: 361048795
Test: th

Change-Id: I1b496de459ab25aebfed2c625bb07d2636a1b190
diff --git a/payload_consumer/verity_writer_android.cc b/payload_consumer/verity_writer_android.cc
index 4a476d2..d808dd5 100644
--- a/payload_consumer/verity_writer_android.cc
+++ b/payload_consumer/verity_writer_android.cc
@@ -78,7 +78,7 @@
     // Encodes |block_size| number of rs blocks each round so that we can read
     // one block each time instead of 1 byte to increase random read
     // performance. This uses about 1 MiB memory for 4K block size.
-    for (size_t j = 0; j < rs_n_; j++) {
+    for (uint64_t j = 0; j < rs_n_; j++) {
       uint64_t offset = fec_ecc_interleave(
           current_round_ * rs_n_ * block_size_ + j, rs_n_, num_rounds_);
       // Don't read past |data_size|, treat them as 0.
@@ -95,11 +95,11 @@
         TEST_AND_RETURN_FALSE(static_cast<size_t>(bytes_read) ==
                               buffer_.size());
       }
-      for (size_t k = 0; k < buffer_.size(); k++) {
+      for (uint64_t k = 0; k < buffer_.size(); k++) {
         rs_blocks_[k * rs_n_ + j] = buffer_[k];
       }
     }
-    for (size_t j = 0; j < block_size_; j++) {
+    for (uint64_t j = 0; j < block_size_; j++) {
       // Encode [j * rs_n_ : (j + 1) * rs_n_) in |rs_blocks| and write
       // |fec_roots| number of parity bytes to |j * fec_roots| in |fec|.
       encode_rs_char(rs_char_.get(),
diff --git a/payload_consumer/verity_writer_android.h b/payload_consumer/verity_writer_android.h
index 1aaafd5..9926988 100644
--- a/payload_consumer/verity_writer_android.h
+++ b/payload_consumer/verity_writer_android.h
@@ -63,8 +63,8 @@
   brillo::Blob fec_;
   brillo::Blob fec_read_;
   EncodeFECStep current_step_;
-  size_t current_round_;
-  size_t num_rounds_;
+  uint64_t current_round_;
+  uint64_t num_rounds_;
   FileDescriptor* read_fd_;
   FileDescriptor* write_fd_;
   uint64_t data_offset_;
@@ -73,7 +73,7 @@
   uint64_t fec_size_;
   uint64_t fec_roots_;
   uint64_t block_size_;
-  size_t rs_n_;
+  uint64_t rs_n_;
   bool verify_mode_;
   std::unique_ptr<void, decltype(&free_rs_char)> rs_char_;
   UnownedCachedFileDescriptor cache_fd_;