Commit graph

58 commits

Author SHA1 Message Date
Elliott Hughes
fee0648121 am d66e949b: am 2e7c39ec: Merge ""adb tcpip" should require a numeric argument."
* commit 'd66e949b14305b367d3de4ba00901bff1122bb0e':
  "adb tcpip" should require a numeric argument.
2015-07-23 02:06:36 +00:00
Elliott Hughes
19d80b878c "adb tcpip" should require a numeric argument.
Defaulting to port 0 just breaks stuff.

Bug: http://b/22636927
Change-Id: I6239900e0828e71b31171d0184c24824957c99c8
2015-07-21 16:27:46 -07:00
Elliott Hughes
e45a665040 am c06c3001: am a1c344b9: Merge "Move mkdirs to adb_utils."
* commit 'c06c3001156cbbdf8d6b3e187e0f92c51c5a80b3':
  Move mkdirs to adb_utils.
2015-07-16 21:39:46 +00:00
Alex Vallée
1421614821 Move mkdirs to adb_utils.
There were duplicate implementations in commandline.cpp and
file_sync_client.cpp.

Change-Id: Ib448f76c0d7ffdcd577336b1c610a881425bc2db
2015-07-15 19:37:18 +00:00
Dan Albert
fcbc32de34 am 00599eca: am e84205bf: Merge "Revert "Turn on -Wformat-nonliteral.""
* commit '00599eca7446f28762da3854566cff0b2ba46799':
  Revert "Turn on -Wformat-nonliteral."
2015-07-09 21:05:16 +00:00
Dan Albert
286bb6ddbd Revert "Turn on -Wformat-nonliteral."
One of my build aliases doesn't play nice with USE_MINGW=1, so my build lied to me. Will revert until I fix it up.

This reverts commit 459df8f3a1.

Change-Id: I7905c5ae5ee85fb2d228ce63d81c79f140998c18
2015-07-09 20:35:09 +00:00
Dan Albert
f9b81ccd75 am fcdc3141: am a35affb5: Merge "Turn on -Wformat-nonliteral."
* commit 'fcdc3141d3209afb8a8a62764fa66911a7104e74':
  Turn on -Wformat-nonliteral.
2015-07-09 20:21:31 +00:00
Dan Albert
459df8f3a1 Turn on -Wformat-nonliteral.
Apparently there are two classes of this warning in clang.
-Wformat-security is only emitted for cases of
`func(nonliteral_fmt_string)` (no args), and -Wformat-nonliteral is
emitted for cases *with* arguments. For whatever reason, the latter
isn't included in -Wextra and must be manually enabled.

To make this more easily portable to Windows, move the existing
gnu_printf/__printf__ decision into base/macros.h as ATTRIBUTE_FORMAT.

Change-Id: I3b0990e1d1f0a2e9c13b32f5cd60478946cb5fc6
2015-07-09 10:47:24 -07:00
Elliott Hughes
5ca8b9b0e6 am dc5993b3: am 4931ae54: Merge "Minor "adb help" fixes."
* commit 'dc5993b3bac7797fb4163e3ea78cdc80f2f0d024':
  Minor "adb help" fixes.
2015-06-13 02:25:37 +00:00
Elliott Hughes
7e067cff7a Minor "adb help" fixes.
One day we should slim this down. (Maybe implement the "help" versus
"help all" distinction that doesn't currently exist but was documented
before this change.)

Bug: https://code.google.com/p/android/issues/detail?id=158394
Change-Id: Ie24b588ffea00d262ce7ab0e5c328120ba8af240
2015-06-12 14:33:17 -07:00
Svetoslav
cb0322f536 am 23d84074: Improve adb install help.
* commit '23d84074652b77385431fc0d1505b7d43b7dba9e':
  Improve adb install help.
2015-06-02 14:22:54 +00:00
Svetoslav
23d8407465 Improve adb install help.
Bug: 21365060
Change-Id: I0a4ea5cf3a2f37a82161b30f7eec5781d175aa8f
2015-06-01 23:59:20 +00:00
Elliott Hughes
06e914eb8e am 5dd45034: am ce817c38: Merge "Fix error handling/reporting for "adb forward" and "adb reverse"."
* commit '5dd45034c3785792c59b3ef663ac2b669637d607':
  Fix error handling/reporting for "adb forward" and "adb reverse".
2015-05-30 01:56:48 +00:00
Elliott Hughes
424af02f36 Fix error handling/reporting for "adb forward" and "adb reverse".
We really need better infrastructure for parsing adb subcommands, but
in the meantime...

At least this cleans up a little more of the implementation too.

Bug: http://b/20736014
Change-Id: I76209847da3724906c71924017bcb69fa31e0b49
2015-05-29 18:03:57 -07:00
Lorenzo Colitti
4209796136 am 0983a6d5: Merge "Document the -g option to adb install." into mnc-dev
* commit '0983a6d54c202fde75523f1340bd9c9a168ab98c':
  Document the -g option to adb install.
2015-05-28 04:06:58 +00:00
Lorenzo Colitti
0b3baac512 Document the -g option to adb install.
Change-Id: I012165df343c24953f1c1cfcdce379bf1b67c624
2015-05-28 12:03:44 +09:00
Spencer Low
6001c87cbc adb: win32: fix StringPrintf format string checking of %zd and PRIu64
At runtime, vsnprintf (and android::base::StringPrintf which calls it)
call a mingw version of vsnprintf, not the vsnprintf from MSVCRT.DLL.
The mingw version properly understands %zd and PRIu64 (the latter,
provided that you #include <inttypes.h>).

The problem was that android::base::StringPrintf was causing
compile-time errors saying that %zd and PRIu64 were not recognized. It
seems that this was because the attribute on the function prototypes
specified `printf' instead of `gnu_printf'. Once that was fixed to match
vsnprintf's attribute, the warnings went away.

This uses similar preprocessor techniques as <android/log.h>.

Also restore a %zd usage to avoid a static_cast<>, and make
print_transfer_progress()'s format string compile-time checkable (and
tweak some types and %llu => PRIu64).

Change-Id: I80b31b9994858a28cb7c6847143b86108b8ab842
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-05-13 19:30:30 -07:00
Elliott Hughes
207ddb20ac Fix "adb remount" for devices without an oem partition.
On a device without an oem partition, we now have an /oem directory
anyway. This causes find_mount to fail, and that was returning nullptr
from a std::string-returning function. Boom!

Also clean up the bits of code I had to trace through between "adb remount"
on the host to the crash on the device as I debugged this.

The only other meaningful change is the error checking in
adb_connect_command --- adb_connect can also return -2.

Bug: http://b/20916855
Change-Id: I4c3b7858e13f3a3a8bbc7d30b3c0ee470bead587
(cherry picked from commit 5677c23e8d)
2015-05-08 10:49:31 -07:00
Elliott Hughes
ee5ce0d14f Merge "Fix "adb remount" for devices without an oem partition." 2015-05-08 17:49:11 +00:00
Elliott Hughes
02418b3e09 Try to include the SHA in a ddmslib-compatible way.
Bug: http://b/20918202
Change-Id: I0c1a48459372b0d28aaf9d09d82540e44b438c9c
(cherry picked from commit f3bbfa6a21)
2015-05-08 09:03:12 -07:00
Elliott Hughes
5677c23e8d Fix "adb remount" for devices without an oem partition.
On a device without an oem partition, we now have an /oem directory
anyway. This causes find_mount to fail, and that was returning nullptr
from a std::string-returning function. Boom!

Also clean up the bits of code I had to trace through between "adb remount"
on the host to the crash on the device as I debugged this.

The only other meaningful change is the error checking in
adb_connect_command --- adb_connect can also return -2.

Bug: http://b/20916855
Change-Id: I4c3b7858e13f3a3a8bbc7d30b3c0ee470bead587
2015-05-08 08:43:10 -07:00
Elliott Hughes
f3bbfa6a21 Try to include the SHA in a ddmslib-compatible way.
Bug: http://b/20918202
Change-Id: I0c1a48459372b0d28aaf9d09d82540e44b438c9c
2015-05-07 21:56:31 -07:00
Spencer Low
142ec75cf8 adb: win32: fix adb emu command
The adb emu command was never working because the socket connection to
the emulator was closed without reading all of the data that the
emulator sent. On Windows, this caused the emulator's recv() call to
error-out, so it never got the command that was sent.

Before settling on this fix, I also experimented changing the arguments
to the socket shutdown() call and that didn't seem to help. I also tried
removing the call to shutdown() and that didn't help. So that should
rule out shutdown() as the problem. One experiment that helped was
delaying before calling adb_close(), but that is of course fragile and
doesn't address the real issue, which is not closing the socket until
the commands have been read.

https://code.google.com/p/android/issues/detail?id=21021

Change-Id: I8fa4d740a2faa2c9922ec50792e16564a94f6eed
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-05-06 18:54:08 -07:00
Dan Albert
c1cfbd304a Include the git sha in the adb version.
Also add --version to adbd to display the same thing.

Change-Id: I47dfbad16c892c42ea938aedd085ba77492791ba
(cherry picked from commit 1ba1d7c1ee)
2015-05-06 09:11:16 -07:00
Dan Albert
1ba1d7c1ee Include the git sha in the adb version.
Also add --version to adbd to display the same thing.

Change-Id: I47dfbad16c892c42ea938aedd085ba77492791ba
2015-05-05 18:04:37 -07:00
Elliott Hughes
9b0f354fa2 Simplify adb_thread_create.
Change-Id: I36d6021ef8fbc23e8bcd4ddbe1dac0eba467cc70
2015-05-05 13:41:21 -07:00
Elliott Hughes
3bd73c12c0 Give enum types CamelCase names for clarity.
Change-Id: I1c89f1cc155ee839f372fb14d972a288183b8bcd
2015-05-05 13:10:43 -07:00
Elliott Hughes
32687beaf2 Remove non-functional "adb persist".
It isn't documented, it doesn't work, and it was only hacked into
"adb shell" anyway. (It's not a bad idea, though, but if we do it
we should do it properly.)

Change-Id: I930a5c6dd1d2850bfdf131f2e989ae04100f7db9
2015-05-05 12:50:26 -07:00
Elliott Hughes
aceb9c08df Implement the ssh(1) escaping rules.
The first rule of ssh(1) escaping is that there is no escaping.

This doesn't undo any of my recent security fixes because they're all
calling escape_arg themselves.

This fixes "adb shell rm /data/dalvik-cache/arm/*".

Also remove do_cmd which caused concern during code review.

Bug: http://b/20564385
Change-Id: I4588fd949d51e2a50cff47ea171ed2d75f402d0d
(cherry picked from commit 2b10111d25)
2015-05-05 12:45:42 -07:00
Elliott Hughes
2b10111d25 Implement the ssh(1) escaping rules.
The first rule of ssh(1) escaping is that there is no escaping.

This doesn't undo any of my recent security fixes because they're all
calling escape_arg themselves.

This fixes "adb shell rm /data/dalvik-cache/arm/*".

Also remove do_cmd which caused concern during code review.

Bug: http://b/20564385
Change-Id: I4588fd949d51e2a50cff47ea171ed2d75f402d0d
2015-05-05 11:17:03 -07:00
Elliott Hughes
e1a55004e9 Add WriteFdFmt and clean up more code.
Also say *which* device wasn't found.

Bug: http://b/20666660
Change-Id: I50e234ad89e39ae0a8995083c0b642c61275c5a3
(cherry picked from commit ab52c181fa)
2015-05-01 17:37:28 -07:00
Elliott Hughes
ab52c181fa Add WriteFdFmt and clean up more code.
Also say *which* device wasn't found.

Bug: http://b/20666660
Change-Id: I50e234ad89e39ae0a8995083c0b642c61275c5a3
2015-05-01 17:36:46 -07:00
Elliott Hughes
92af733ee2 More adb buffer fixes.
This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.

ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.

Also actually build the device tracker test tool (and remove its duplicate).

Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
(cherry picked from commit e67f1f87d9)
2015-05-01 17:09:34 -07:00
Elliott Hughes
e67f1f87d9 More adb buffer fixes.
This patch factors out a lot of the basic protocol code: sending OKAY,
sending FAIL, and sending a length-prefixed string.

ADB_TRACE has been non-optional for a long time, so let's just remove
the #ifs.

Also actually build the device tracker test tool (and remove its duplicate).

Bug: http://b/20666660
Change-Id: I6c7d59f18707bdc62ca69dea45547617f9f31fc6
2015-05-01 15:55:37 -07:00
Elliott Hughes
f1a58f8f33 More fixed-length buffer removal.
Bug: http://b/20666660
Change-Id: I0c738e9fed2defed48a9cf2d0a4f7b99c08dcf3d
(cherry picked from commit 6452a89aa8)
2015-04-30 12:31:11 -07:00
Elliott Hughes
6452a89aa8 More fixed-length buffer removal.
Bug: http://b/20666660
Change-Id: I0c738e9fed2defed48a9cf2d0a4f7b99c08dcf3d
2015-04-30 11:25:05 -07:00
Elliott Hughes
71aeb79815 Move __adb_error to std::string, and improve various errors.
Also remove an sprintf. Also fix various bits of code that were
reporting stale adb_error values when they meant strerror.

(cherry-pick of 078f0fcf4c63b8d8e8c10a18855eae04ca321e06.)

Bug: http://b/20666660
Change-Id: Ibeb48b7bc21bb0ec30ba47889d1d671ee480e1b7
2015-04-29 11:42:13 -07:00
Elliott Hughes
078f0fcf4c Move __adb_error to std::string, and improve various errors.
Also remove an sprintf. Also fix various bits of code that were
reporting stale adb_error values when they meant strerror.

Bug: http://b/20666660
Change-Id: Ibeb48b7bc21bb0ec30ba47889d1d671ee480e1b7
2015-04-29 11:28:37 -07:00
Elliott Hughes
876881b22a Merge "Add missing null checks after allocations." 2015-04-22 20:05:46 +00:00
Elliott Hughes
dc3b459ff9 Add missing null checks after allocations.
Bug: http://b/20317729
Change-Id: I62bb761d48ee59a1f4ddd0cdd0632432305ca2ca
2015-04-21 19:43:22 -07:00
Elliott Hughes
1555147bc4 Plumb more of the error reporting through.
This doesn't fix the bug, but it does flatten the bug to the well-known
and long-standing "adb shell" doesn't return exit statuses, so when we
fix that, this one will fix itself.

Bug: http://b/20423886
Change-Id: I48351e46f05dd3f2f6e57f0df1d851333458d0ef
2015-04-21 17:58:55 -07:00
Elliott Hughes
d236d071b9 Fix "adb sync" for devices without vendor and oem.
Bug: http://b/20440110
Change-Id: I2481992198890f5ca50412c2b7ca361101961413
2015-04-21 10:17:07 -07:00
Elliott Hughes
53daee6a2b Fix the Windows adb build.
It looks like we can't use clang on Windows yet because libc++ isn't ready.
So move back to GCC for the Windows host clang. Work around the mingw
printf format string problems that made us want to switch to clang in the
first place, and #include "sysdeps.h" in adb_utils.cpp to work around the
absence of lstat(2) on Windows.

Change-Id: Icd0797a8c0c2d1d326bdd704ba6bcafcbaeb742f
2015-04-19 13:17:01 -07:00
Elliott Hughes
6c34bbaa68 Use escape_arg in "adb backup".
This doesn't fix the injection vulnerability, but it makes "adb backup"
no worse than the other commands, and lets me fix them all at once.

Bug: 20323053
Change-Id: I39843c065d9d738b6b7943b2ffd660e4a031cc36
2015-04-17 20:30:09 -07:00
Elliott Hughes
a7090b94c1 Remove yet more fixed-length buffers (and their overruns).
Bug: 20317724
Change-Id: If137fc96f5f23576ccecd388ac87afefa47337c6
2015-04-17 17:58:35 -07:00
Elliott Hughes
61a004c05f Merge "Fix more buffer overruns." 2015-04-17 22:24:27 +00:00
Elliott Hughes
5830577bd8 Fix more buffer overruns.
Also add some tests.

Bug: 20323050
Change-Id: I9eaf3dc04efd85206663c4cca4f8c1208620a89a
2015-04-17 15:23:31 -07:00
Elliott Hughes
2940ccff86 Use PRI* macros to fix the Windows build.
Change-Id: Icd400be05c2bc726265832875b5a05dba7966847
2015-04-17 14:07:52 -07:00
Elliott Hughes
2baae3a876 Remove various fixed-length buffers (and their overflows).
Bug: 20323052
Bug: 20323051
Bug: 20317728
Bug: 20317727
Bug: 20317726
Bug: 20317725
Change-Id: I57a5e30a5b7867715f55cee7429aa36d7ce21484
2015-04-17 10:59:34 -07:00
Elliott Hughes
a2f2e56796 Move sysdeps_win32 to C++.
Change-Id: I27ca41b64d62bb3611b3a39a5c3bb4377d0773bc
2015-04-16 16:47:02 -07:00