diff options
author | Elliott Hughes <enh@google.com> | 2015-04-17 13:57:15 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-04-17 15:23:31 -0700 |
commit | 5830577bd82fdb7c39555da20a4cf585b8bb376a (patch) | |
tree | 2048ea400874a96c38d74ed36f8ca20928f61f23 /adb/remount_service.cpp | |
parent | 3538b40942b65927e65b446bca9842a9f915c5e3 (diff) | |
download | system_core-5830577bd82fdb7c39555da20a4cf585b8bb376a.zip system_core-5830577bd82fdb7c39555da20a4cf585b8bb376a.tar.gz system_core-5830577bd82fdb7c39555da20a4cf585b8bb376a.tar.bz2 |
Fix more buffer overruns.
Also add some tests.
Bug: 20323050
Change-Id: I9eaf3dc04efd85206663c4cca4f8c1208620a89a
Diffstat (limited to 'adb/remount_service.cpp')
-rw-r--r-- | adb/remount_service.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/adb/remount_service.cpp b/adb/remount_service.cpp index b150274..1eaee73 100644 --- a/adb/remount_service.cpp +++ b/adb/remount_service.cpp @@ -31,6 +31,7 @@ #include "adb.h" #include "adb_io.h" +#include "adb_utils.h" #include "cutils/properties.h" static int system_ro = 1; @@ -56,11 +57,6 @@ static std::string find_mount(const char *dir) { return device; } -static bool has_partition(const char* path) { - struct stat sb; - return (lstat(path, &sb) == 0 && S_ISDIR(sb.st_mode)); -} - int make_block_device_writable(const std::string& dev) { int fd = unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC); if (fd == -1) { @@ -90,7 +86,7 @@ static int remount(const char* dir, int* dir_ro) { } static bool remount_partition(int fd, const char* partition, int* ro) { - if (!has_partition(partition)) { + if (!directory_exists(partition)) { return true; } if (remount(partition, ro)) { |