Merge "base: rename unique_fd::clear() to unique_fd::reset()."
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 77c5f96..a9185a0 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -37,6 +37,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/parseint.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -1549,23 +1550,32 @@
// If -L, -H, or -P are specified, ignore environment variables.
// Otherwise, prefer ADB_SERVER_SOCKET over ANDROID_ADB_SERVER_ADDRESS/PORT.
- if (!(server_host_str || server_port_str || server_socket_str)) {
- server_socket_str = server_socket_str ? server_socket_str : getenv("ADB_SERVER_SOCKET");
+ if (!server_host_str && !server_port_str && !server_socket_str) {
+ server_socket_str = getenv("ADB_SERVER_SOCKET");
}
if (!server_socket_str) {
// tcp:1234 and tcp:localhost:1234 are different with -a, so don't default to localhost
server_host_str = server_host_str ? server_host_str : getenv("ANDROID_ADB_SERVER_ADDRESS");
- long server_port = DEFAULT_ADB_PORT;
+ int server_port = DEFAULT_ADB_PORT;
server_port_str = server_port_str ? server_port_str : getenv("ANDROID_ADB_SERVER_PORT");
+ if (server_port_str && strlen(server_port_str) > 0) {
+ if (!android::base::ParseInt(server_port_str, &server_port, 1, 65535)) {
+ fprintf(stderr,
+ "adb: Env var ANDROID_ADB_SERVER_PORT must be a positive"
+ " number less than 65535. Got \"%s\"\n",
+ server_port_str);
+ exit(1);
+ }
+ }
int rc;
char* temp;
if (server_host_str) {
- rc = asprintf(&temp, "tcp:%s:%ld", server_host_str, server_port);
+ rc = asprintf(&temp, "tcp:%s:%d", server_host_str, server_port);
} else {
- rc = asprintf(&temp, "tcp:%ld", server_port);
+ rc = asprintf(&temp, "tcp:%d", server_port);
}
if (rc < 0) {
fatal("failed to allocate server socket specification");
diff --git a/include/ziparchive/zip_archive.h b/include/ziparchive/zip_archive.h
index 7dc60ae..4f68c3b 100644
--- a/include/ziparchive/zip_archive.h
+++ b/include/ziparchive/zip_archive.h
@@ -43,8 +43,7 @@
/*
* entry_name has to be an c-style string with only ASCII characters.
*/
- explicit ZipString(const char* entry_name)
- : name(reinterpret_cast<const uint8_t*>(entry_name)), name_length(strlen(entry_name)) {}
+ explicit ZipString(const char* entry_name);
bool operator==(const ZipString& rhs) const {
return name && (name_length == rhs.name_length) &&
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 350be31..4649a75 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -31,6 +31,7 @@
#include <vector>
#include "android-base/file.h"
+#include "android-base/logging.h"
#include "android-base/macros.h" // TEMP_FAILURE_RETRY may or may not be in unistd
#include "android-base/memory.h"
#include "log/log.h"
@@ -1073,3 +1074,10 @@
int GetFileDescriptor(const ZipArchiveHandle handle) {
return reinterpret_cast<ZipArchive*>(handle)->fd;
}
+
+ZipString::ZipString(const char* entry_name)
+ : name(reinterpret_cast<const uint8_t*>(entry_name)) {
+ size_t len = strlen(entry_name);
+ CHECK_LE(len, static_cast<size_t>(UINT16_MAX));
+ name_length = static_cast<uint16_t>(len);
+}
diff --git a/libziparchive/zip_writer.cc b/libziparchive/zip_writer.cc
index 1ebed30..b72ed7f 100644
--- a/libziparchive/zip_writer.cc
+++ b/libziparchive/zip_writer.cc
@@ -243,8 +243,12 @@
// Initialize the z_stream for compression.
z_stream_ = std::unique_ptr<z_stream, void(*)(z_stream*)>(new z_stream(), DeleteZStream);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
int zerr = deflateInit2(z_stream_.get(), Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS,
DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
+#pragma GCC diagnostic pop
+
if (zerr != Z_OK) {
if (zerr == Z_VERSION_ERROR) {
ALOGE("Installed zlib is not compatible with linked version (%s)", ZLIB_VERSION);
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 43822f3..1a601f0 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -359,7 +359,8 @@
# Fix the access permissions and group ownership for 'bt_config.conf'
chmod 0660 /data/misc/bluedroid/bt_config.conf
chown bluetooth net_bt_stack /data/misc/bluedroid/bt_config.conf
- mkdir /data/misc/bluetooth 0770 system system
+ mkdir /data/misc/bluetooth 0770 bluetooth net_bt_stack
+ mkdir /data/misc/bluetooth/logs 0770 bluetooth net_bt_stack
mkdir /data/misc/keystore 0700 keystore keystore
mkdir /data/misc/gatekeeper 0700 system system
mkdir /data/misc/keychain 0771 system system