Refuse to push a non-regular file server

If SCRCPY_SERVER_PATH points to a directory, then a directory will be
pushed to /data/local/tmp/scrcpy-server.jar.

When executing it, app_process will just abort and leave the directory
on the device, causing scrcpy to always fail.

To avoid the problem, check that the server is a regular file before
pushing it.

Closes #956 <https://github.com/Genymobile/scrcpy/issues/956>
This commit is contained in:
Romain Vimont
2019-12-05 21:07:11 +01:00
parent 3259c60b22
commit 64bcac9157
3 changed files with 24 additions and 1 deletions

View File

@@ -67,7 +67,12 @@ get_server_path(void) {
static bool
push_server(const char *serial) {
process_t process = adb_push(serial, get_server_path(), DEVICE_SERVER_PATH);
const char *server_path = get_server_path();
if (!is_regular_file(server_path)) {
LOGE("'%s' does not exist or is not a regular file\n", server_path);
return false;
}
process_t process = adb_push(serial, server_path, DEVICE_SERVER_PATH);
return process_check_success(process, "adb push");
}