From f7466f9f2334b0e9025e1c7ecf65b4d04a246b20 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 27 Apr 2015 18:39:27 -0700 Subject: Stop using adb_strtok, and check argument validity. (cherry picked from commit ba45ddf37cf4543143af6b2e27fc1214f3dbe892) Change-Id: Iba4f77f7db54ca0184437bd8ea96abfadabc72a3 --- minadbd/services.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'minadbd') diff --git a/minadbd/services.cpp b/minadbd/services.cpp index a832567..dd1fd7c 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -43,15 +43,16 @@ void* service_bootstrap_func(void* x) { return 0; } -static void sideload_host_service(int sfd, void* cookie) { - char* saveptr; - const char* s = adb_strtok_r(reinterpret_cast(cookie), ":", &saveptr); - uint64_t file_size = strtoull(s, NULL, 10); - s = adb_strtok_r(NULL, ":", &saveptr); - uint32_t block_size = strtoul(s, NULL, 10); - - printf("sideload-host file size %" PRIu64 " block size %" PRIu32 "\n", - file_size, block_size); +static void sideload_host_service(int sfd, void* data) { + const char* args = reinterpret_cast(data); + int file_size; + int block_size; + if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) { + printf("bad sideload-host arguments: %s\n", args); + exit(1); + } + + printf("sideload-host file size %d block size %d\n", file_size, block_size); int result = run_adb_fuse(sfd, file_size, block_size); -- cgit v1.1