Merge "Increase the maximum shell command length to 4096ish." am: 3472410eac
am: 2783126cab
* commit '2783126cab5ca2a1aae5779c988a84abff97cb19':
Increase the maximum shell command length to 4096ish.
diff --git a/adb/adb.cpp b/adb/adb.cpp
index c03d7db..484e561 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -857,8 +857,7 @@
#if ADB_HOST
SendOkay(reply_fd);
#endif
- SendProtocolString(reply_fd, listeners);
- return 1;
+ return SendProtocolString(reply_fd, listeners);
}
if (!strcmp(service, "killforward-all")) {
diff --git a/adb/adb_client.cpp b/adb/adb_client.cpp
index cb5e488..bbc4dc7 100644
--- a/adb/adb_client.cpp
+++ b/adb/adb_client.cpp
@@ -124,7 +124,7 @@
int _adb_connect(const std::string& service, std::string* error) {
D("_adb_connect: %s", service.c_str());
- if (service.empty() || service.size() > 1024) {
+ if (service.empty() || service.size() > MAX_PAYLOAD_V1) {
*error = android::base::StringPrintf("bad service name length (%zd)",
service.size());
return -1;
diff --git a/adb/adb_io.cpp b/adb/adb_io.cpp
index 176b7bd..ae16834 100644
--- a/adb/adb_io.cpp
+++ b/adb/adb_io.cpp
@@ -22,14 +22,16 @@
#include <android-base/stringprintf.h>
+#include "adb.h"
#include "adb_trace.h"
#include "adb_utils.h"
#include "sysdeps.h"
bool SendProtocolString(int fd, const std::string& s) {
- int length = s.size();
- if (length > 0xffff) {
- length = 0xffff;
+ unsigned int length = s.size();
+ if (length > MAX_PAYLOAD_V1 - 4) {
+ errno = EMSGSIZE;
+ return false;
}
// The cost of sending two strings outweighs the cost of formatting.
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index eb0ce85..d8e4e93 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -698,17 +698,17 @@
p = s->pkt_first;
}
- /* don't bother if we can't decode the length */
+ /* don't bother if we can't decode the length */
if(p->len < 4) return 0;
len = unhex(p->data, 4);
- if((len < 1) || (len > 1024)) {
+ if ((len < 1) || (len > MAX_PAYLOAD_V1)) {
D("SS(%d): bad size (%d)", s->id, len);
goto fail;
}
D("SS(%d): len is %d", s->id, len );
- /* can't do anything until we have the full header */
+ /* can't do anything until we have the full header */
if((len + 4) > p->len) {
D("SS(%d): waiting for %d more bytes", s->id, len+4 - p->len);
return 0;