From ccafc79de7c46c53c33f38a6623f6d2d379d3d58 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Thu, 14 Apr 2016 17:18:04 -0400 Subject: [PATCH] Fix NULL deref on exec-in with insufficient arguments (cherry-pick of 566a28169b84836fddd5ae96db9b147237ea054f.) Bug: 28152091 Change-Id: Ib59e3bf7f26974aa09d2e6a0e1d9281d7ce25511 --- adb/commandline.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/adb/commandline.cpp b/adb/commandline.cpp index d8b165475..45c6142e5 100644 --- a/adb/commandline.cpp +++ b/adb/commandline.cpp @@ -1613,6 +1613,11 @@ int adb_commandline(int argc, const char **argv) { else if (!strcmp(argv[0], "exec-in") || !strcmp(argv[0], "exec-out")) { int exec_in = !strcmp(argv[0], "exec-in"); + if (argc < 2) { + fprintf(stderr, "Usage: adb %s command\n", argv[0]); + return 1; + } + std::string cmd = "exec:"; cmd += argv[1]; argc -= 2;