summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorSpencer Low <CompareAndSwap@gmail.com>2015-05-07 19:08:29 -0700
committerElliott Hughes <enh@google.com>2015-06-12 11:02:37 -0700
commitd62bce804005ef55bba90b9513a17db63c186ab3 (patch)
tree29ef2bb5029db0a09c549f44967074543df29d26 /adb
parent350926ef2f13f75335b32e9904dc0b46c01ab1fe (diff)
downloadsystem_core-d62bce804005ef55bba90b9513a17db63c186ab3.zip
system_core-d62bce804005ef55bba90b9513a17db63c186ab3.tar.gz
system_core-d62bce804005ef55bba90b9513a17db63c186ab3.tar.bz2
adb: win32: fix key files reading/writing
The issue is that adb uses fopen() with "e" (presumably to open the file with O_CLOEXEC), but that flag causes MSVCRT.DLL to return an error. So when adb_auth_host.cpp goes to read or write the adbkey files, it fails. The quick fix is to not use the "e" option on adb host code since it isn't necessary there, compared to adbd. An alternative fix would be to have a fopen() wrapper on Windows that filters out the "e" option. Bug: http://b/21806456 Bug: https://code.google.com/p/android/issues/detail?id=175077 Change-Id: I7d8ba2847dab0ed558ffe156e79093251eb253c9 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com> (cherry picked from commit 9b9603148b0a42ee9b4fc2df76bfde31ba29c311)
Diffstat (limited to 'adb')
-rw-r--r--adb/adb_auth_host.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/adb/adb_auth_host.cpp b/adb/adb_auth_host.cpp
index 510dcc2..61a3777 100644
--- a/adb/adb_auth_host.cpp
+++ b/adb/adb_auth_host.cpp
@@ -173,7 +173,7 @@ static int write_public_keyfile(RSA *private_key, const char *private_key_path)
return 0;
}
- outfile = fopen(path, "we");
+ outfile = fopen(path, "w");
if (!outfile) {
D("Failed to open '%s'\n", path);
return 0;
@@ -239,7 +239,7 @@ static int generate_key(const char *file)
old_mask = umask(077);
- f = fopen(file, "we");
+ f = fopen(file, "w");
if (!f) {
D("Failed to open '%s'\n", file);
umask(old_mask);
@@ -273,7 +273,7 @@ static int read_key(const char *file, struct listnode *list)
{
D("read_key '%s'\n", file);
- FILE* fp = fopen(file, "re");
+ FILE* fp = fopen(file, "r");
if (!fp) {
D("Failed to open '%s': %s\n", file, strerror(errno));
return 0;