diff options
author | Snild Dolkow <snild.dolkow@sonymobile.com> | 2014-01-30 10:08:38 +0100 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonymobile.com> | 2014-02-21 14:57:02 +0100 |
commit | 2264e7cfef6b1236a90a13b1d99abb4aadcb0b93 (patch) | |
tree | 4c893e05b20f21dbafb54238b64ce12d31c2c6a3 /adb/adb_client.c | |
parent | 536dce31d35e9411c03102d6abd837cd4d54ce55 (diff) | |
download | system_core-2264e7cfef6b1236a90a13b1d99abb4aadcb0b93.zip system_core-2264e7cfef6b1236a90a13b1d99abb4aadcb0b93.tar.gz system_core-2264e7cfef6b1236a90a13b1d99abb4aadcb0b93.tar.bz2 |
Fix adb forward --list when forwarding a lot
The list action had some problems with large numbers of forwards:
* adb_query() limited replies to 1024 B (and the print was useless)
* the reply header's length could overflow (also in other commands)
* ...and the client had no way of detecting it
* writex() didn't retry on EAGAIN ("Resource temporarily unavailable")
This patch makes all "OKAY%04x" replies use a common function which
checks the length and limits it to 0xffff. This means that the client
can easily check for truncated replies.
Before: forward --list starts failing at 15-30 forwards (depending on
device serial and forward spec lengths).
After: no problems with forward --list.
Change-Id: Ie1e82c4d622f5c56e51abb26533ba17d40459914
Diffstat (limited to 'adb/adb_client.c')
-rw-r--r-- | adb/adb_client.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/adb/adb_client.c b/adb/adb_client.c index 586cd7b..1e47486 100644 --- a/adb/adb_client.c +++ b/adb/adb_client.c @@ -324,7 +324,10 @@ char *adb_query(const char *service) buf[4] = 0; n = strtoul(buf, 0, 16); - if(n > 1024) goto oops; + if(n >= 0xffff) { + strcpy(__adb_error, "reply is too long (>= 64kB)"); + goto oops; + } tmp = malloc(n + 1); if(tmp == 0) goto oops; |