cow estimator: terminate on bad write

If a write failure occurs, we should log an error and then terminate
estimation. Otherwise we might have a false positive, and have a faulty
OTA package generated

Bug: 332640740
Test: th
Change-Id: Ib72a7b66b7f0c25b89be64172ce68d1de077077e
diff --git a/payload_generator/cow_size_estimator.cc b/payload_generator/cow_size_estimator.cc
index cc1034d..2a97b06 100644
--- a/payload_generator/cow_size_estimator.cc
+++ b/payload_generator/cow_size_estimator.cc
@@ -99,7 +99,12 @@
               PLOG(ERROR) << "Failed to read target data at " << ext;
               return false;
             }
-            writer->Write(new_data.data(), ext.num_blocks() * block_size);
+            if (!writer->Write(new_data.data(),
+                               ext.num_blocks() * block_size)) {
+              LOG(ERROR) << "Failed to write XOR operation for extent: "
+                         << ext.start_block();
+              return false;
+            }
           }
           cow_writer->AddLabel(0);
           break;
@@ -122,7 +127,11 @@
             PLOG(ERROR) << "Failed to read new block data at " << ext;
             return false;
           }
-          extent_writer.Write(data.data(), data.size());
+          if (!extent_writer.Write(data.data(), data.size())) {
+            LOG(ERROR) << "Failed to write REPLACE op for extent: "
+                       << ext.start_block();
+            return false;
+          }
         }
         cow_writer->AddLabel(0);
         break;