Support reading output from IptablesRestoreController.

Add the ability to IptablesRestoreController to return the output
of a command. This is useful to run commands that list chains or
return counters through the ip[6]tables-restore.

Also enable unsigned-integer-overflow sanitization the unit tests
because their behaviour should be representative of actual code.
Having address sanitization enabled would have saved a fair
amount of time debugging an on-device abort() that did not affect
the tests.

Test: new unit test passes
Bug: 32323979
Change-Id: I70726ebbade0cb792aba38787c57378df177f2d8
diff --git a/server/IptablesRestoreController.h b/server/IptablesRestoreController.h
index 4279fac..f7ae292 100644
--- a/server/IptablesRestoreController.h
+++ b/server/IptablesRestoreController.h
@@ -34,6 +34,9 @@
     // Execute |commands| on the given |target|.
     int execute(const IptablesTarget target, const std::string& commands);
 
+    // Execute |commands| on the given |target|, and populate |output| with stdout.
+    int execute(const IptablesTarget target, const std::string& commands, std::string *output);
+
     enum IptablesProcessType {
         IPTABLES_PROCESS,
         IP6TABLES_PROCESS,
@@ -53,11 +56,12 @@
 private:
     static IptablesProcess* forkAndExec(const IptablesProcessType type);
 
-    int sendCommand(const IptablesProcessType type, const std::string& command);
+    int sendCommand(const IptablesProcessType type, const std::string& command,
+                    std::string *output);
 
     static std::string fixCommandString(const std::string& command);
 
-    bool drainAndWaitForAck(const std::unique_ptr<IptablesProcess> &process);
+    bool drainAndWaitForAck(const std::unique_ptr<IptablesProcess> &process, std::string *output);
 
     static void maybeLogStderr(const std::unique_ptr<IptablesProcess> &process,
                                const char* buf, const ssize_t numBytes);