Loading adb/adb_client.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ bool adb_status(int fd, std::string* error) { static int _adb_connect(const std::string& service, std::string* error) { D("_adb_connect: %s", service.c_str()); if (service.empty() || service.size() > MAX_PAYLOAD_V1) { if (service.empty() || service.size() > MAX_PAYLOAD) { *error = android::base::StringPrintf("bad service name length (%zd)", service.size()); return -1; Loading adb/adb_io.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ bool SendProtocolString(int fd, const std::string& s) { unsigned int length = s.size(); if (length > MAX_PAYLOAD_V1 - 4) { if (length > MAX_PAYLOAD - 4) { errno = EMSGSIZE; return false; } Loading adb/commandline.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -599,6 +599,13 @@ static int RemoteShell(bool use_shell_protocol, const std::string& type_arg, std::string service_string = ShellServiceString(use_shell_protocol, type_arg, command); // Old devices can't handle a service string that's longer than MAX_PAYLOAD_V1. // Use |use_shell_protocol| to determine whether to allow a command longer than that. if (service_string.size() > MAX_PAYLOAD_V1 && !use_shell_protocol) { fprintf(stderr, "error: shell command too long\n"); return 1; } // Make local stdin raw if the device allocates a PTY, which happens if: // 1. We are explicitly asking for a PTY shell, or // 2. We don't specify shell type and are starting an interactive session. Loading adb/sockets.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -686,7 +686,7 @@ static int smart_socket_enqueue(asocket* s, apacket* p) { } len = unhex(p->data, 4); if ((len < 1) || (len > MAX_PAYLOAD_V1)) { if ((len < 1) || (len > MAX_PAYLOAD)) { D("SS(%d): bad size (%d)", s->id, len); goto fail; } Loading adb/test_device.py +7 −0 Original line number Diff line number Diff line Loading @@ -342,6 +342,13 @@ class ShellTest(DeviceTest): out = self.device.shell(['echo', 'foo'])[0] self.assertEqual(out, 'foo' + self.device.linesep) def test_shell_command_length(self): # Devices that have shell_v2 should be able to handle long commands. if self.device.has_shell_protocol(): rc, out, err = self.device.shell_nocheck(['echo', 'x' * 16384]) self.assertEqual(rc, 0) self.assertTrue(out == ('x' * 16384 + '\n')) def test_shell_nocheck_failure(self): rc, out, _ = self.device.shell_nocheck(['false']) self.assertNotEqual(rc, 0) Loading Loading
adb/adb_client.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ bool adb_status(int fd, std::string* error) { static int _adb_connect(const std::string& service, std::string* error) { D("_adb_connect: %s", service.c_str()); if (service.empty() || service.size() > MAX_PAYLOAD_V1) { if (service.empty() || service.size() > MAX_PAYLOAD) { *error = android::base::StringPrintf("bad service name length (%zd)", service.size()); return -1; Loading
adb/adb_io.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ bool SendProtocolString(int fd, const std::string& s) { unsigned int length = s.size(); if (length > MAX_PAYLOAD_V1 - 4) { if (length > MAX_PAYLOAD - 4) { errno = EMSGSIZE; return false; } Loading
adb/commandline.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -599,6 +599,13 @@ static int RemoteShell(bool use_shell_protocol, const std::string& type_arg, std::string service_string = ShellServiceString(use_shell_protocol, type_arg, command); // Old devices can't handle a service string that's longer than MAX_PAYLOAD_V1. // Use |use_shell_protocol| to determine whether to allow a command longer than that. if (service_string.size() > MAX_PAYLOAD_V1 && !use_shell_protocol) { fprintf(stderr, "error: shell command too long\n"); return 1; } // Make local stdin raw if the device allocates a PTY, which happens if: // 1. We are explicitly asking for a PTY shell, or // 2. We don't specify shell type and are starting an interactive session. Loading
adb/sockets.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -686,7 +686,7 @@ static int smart_socket_enqueue(asocket* s, apacket* p) { } len = unhex(p->data, 4); if ((len < 1) || (len > MAX_PAYLOAD_V1)) { if ((len < 1) || (len > MAX_PAYLOAD)) { D("SS(%d): bad size (%d)", s->id, len); goto fail; } Loading
adb/test_device.py +7 −0 Original line number Diff line number Diff line Loading @@ -342,6 +342,13 @@ class ShellTest(DeviceTest): out = self.device.shell(['echo', 'foo'])[0] self.assertEqual(out, 'foo' + self.device.linesep) def test_shell_command_length(self): # Devices that have shell_v2 should be able to handle long commands. if self.device.has_shell_protocol(): rc, out, err = self.device.shell_nocheck(['echo', 'x' * 16384]) self.assertEqual(rc, 0) self.assertTrue(out == ('x' * 16384 + '\n')) def test_shell_nocheck_failure(self): rc, out, _ = self.device.shell_nocheck(['false']) self.assertNotEqual(rc, 0) Loading