diff --git a/adb/commandline.c b/adb/commandline.c index 2df3f0967..b268ca5e8 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -1746,9 +1746,10 @@ top: return 1; } +#define MAX_ARGV_LENGTH 16 static int do_cmd(transport_type ttype, char* serial, char *cmd, ...) { - char *argv[16]; + char *argv[MAX_ARGV_LENGTH]; int argc; va_list ap; @@ -1765,7 +1766,9 @@ static int do_cmd(transport_type ttype, char* serial, char *cmd, ...) } argv[argc++] = cmd; - while((argv[argc] = va_arg(ap, char*)) != 0) argc++; + while(argc < MAX_ARGV_LENGTH && + (argv[argc] = va_arg(ap, char*)) != 0) argc++; + assert(argc < MAX_ARGV_LENGTH); va_end(ap); #if 0