From 6ca9825c0f54b2d8cd11c01c6faa970bfec96330 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 5 Feb 2022 10:11:13 +0100 Subject: [PATCH] Assert "adb disconnect" is called with an argument Calling "adb disconnect" without argument would disconnect every TCP/IP device. We must make sure scrcpy never does that. --- app/src/adb/adb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/adb/adb.c b/app/src/adb/adb.c index 4810dcbd..b6084129 100644 --- a/app/src/adb/adb.c +++ b/app/src/adb/adb.c @@ -364,11 +364,10 @@ sc_adb_connect(struct sc_intr *intr, const char *ip_port, unsigned flags) { bool sc_adb_disconnect(struct sc_intr *intr, const char *ip_port, unsigned flags) { + assert(ip_port); const char *const adb_cmd[] = {"disconnect", ip_port}; - size_t len = ip_port ? ARRAY_LEN(adb_cmd) - : ARRAY_LEN(adb_cmd) - 1; - sc_pid pid = sc_adb_execute(NULL, adb_cmd, len, flags); + sc_pid pid = sc_adb_execute(NULL, adb_cmd, ARRAY_LEN(adb_cmd), flags); return process_check_success_intr(intr, pid, "adb disconnect", flags); }