summaryrefslogtreecommitdiffstats
path: root/adb/adb_io.cpp
diff options
context:
space:
mode:
authorAlex Buynytskyy <alexbuy@google.com>2018-12-20 10:09:43 -0800
committerAlex Buynytskyy <alexbuy@google.com>2018-12-20 10:11:15 -0800
commita9e79489dc497c3b7db10aac7cb0bb95c94447b7 (patch)
treeb1f6e966bf708329fd7f8e15e652791ace77d7e0 /adb/adb_io.cpp
parentd1ff11b94aa8752705314665f2930b10f4afb65f (diff)
downloadsystem_core-a9e79489dc497c3b7db10aac7cb0bb95c94447b7.tar.gz
system_core-a9e79489dc497c3b7db10aac7cb0bb95c94447b7.tar.bz2
system_core-a9e79489dc497c3b7db10aac7cb0bb95c94447b7.zip
Minor refactor to support strings with embedded zeros.
Test: manual Change-Id: Iaece3003deb257cbcae65a23a4c4a1ccfd690d49
Diffstat (limited to 'adb/adb_io.cpp')
-rw-r--r--adb/adb_io.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/adb/adb_io.cpp b/adb/adb_io.cpp
index 6cc274bbe..e6fefdae2 100644
--- a/adb/adb_io.cpp
+++ b/adb/adb_io.cpp
@@ -38,7 +38,8 @@ bool SendProtocolString(int fd, const std::string& s) {
// The cost of sending two strings outweighs the cost of formatting.
// "adb sync" performance is affected by this.
- return WriteFdFmt(fd, "%04x%.*s", length, length, s.c_str());
+ auto str = android::base::StringPrintf("%04x", length).append(s);
+ return WriteFdExactly(fd, str);
}
bool ReadProtocolString(int fd, std::string* s, std::string* error) {