Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ef5bf83 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Fix buffer overrun in adb wait-for-device.

Bug: http://b/27444063

(cherry picked from commit 34e560b9)

Change-Id: Ic71cb2070f509d76fb4208dbab6711c5dd5e1f62
parent 87c4210a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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))) {