Merge "Fix buffer overrun in adb wait-for-device."

am: 1f13c1a208

* commit '1f13c1a208394b74a8c60e677546a8c8ed697091':
  Fix buffer overrun in adb wait-for-device.
This commit is contained in:
Elliott Hughes 2016-03-11 17:01:53 +00:00 committed by android-build-merger
commit b80557a608

View file

@ -1029,8 +1029,8 @@ static bool check_wait_for_device_syntax(const char* service) {
// TODO: when we have libc++ for Windows, use a regular expression instead.
// wait-for-((any|local|usb)-)?(bootloader|device|recovery|sideload)
char type[20];
char state[20];
char type[20 + 1]; // sscanf's %20[...] doesn't include the NUL.
char state[20 + 1];
int length = 0;
if (sscanf(service, "wait-for-%20[a-z]-%20[a-z]%n", type, state, &length) < 2 ||
length != static_cast<int>(strlen(service))) {