summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
Diffstat (limited to 'adb')
-rw-r--r--adb/Android.mk13
-rw-r--r--adb/adb.c7
-rw-r--r--adb/adb_auth_host.c66
-rw-r--r--adb/usb_osx.c3
-rwxr-xr-xadb/usb_vendors.c9
5 files changed, 74 insertions, 24 deletions
diff --git a/adb/Android.mk b/adb/Android.mk
index 3643aa5..c458ecb 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -24,6 +24,7 @@ ifeq ($(HOST_OS),darwin)
USB_SRCS := usb_osx.c
EXTRA_SRCS := get_my_path_darwin.c
LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
+ LOCAL_CFLAGS += -Wno-sizeof-pointer-memaccess -Wno-unused-parameter
endif
ifeq ($(HOST_OS),freebsd)
@@ -82,6 +83,7 @@ ifeq ($(USE_SYSDEPS_WIN32),)
LOCAL_STATIC_LIBRARIES += libcutils
endif
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_HOST_EXECUTABLE)
$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
@@ -113,8 +115,13 @@ LOCAL_SRC_FILES := \
remount_service.c \
usb_linux_client.c
-LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter -Werror
-LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
+LOCAL_CFLAGS := \
+ -O2 \
+ -g \
+ -DADB_HOST=0 \
+ -D_XOPEN_SOURCE \
+ -D_GNU_SOURCE \
+ -Wall -Wno-unused-parameter -Werror -Wno-deprecated-declarations \
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
@@ -127,6 +134,7 @@ LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
LOCAL_STATIC_LIBRARIES := liblog libcutils libc libmincrypt libselinux
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_EXECUTABLE)
@@ -169,5 +177,6 @@ LOCAL_STATIC_LIBRARIES := libzipfile libunz libcutils liblog
LOCAL_SHARED_LIBRARIES := libcrypto
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_EXECUTABLE)
endif
diff --git a/adb/adb.c b/adb/adb.c
index 10a1e0d..cf8e3c4 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -329,6 +329,7 @@ static void send_msg_with_header(int fd, const char* msg, size_t msglen) {
}
#endif
+#if ADB_HOST
static void send_msg_with_okay(int fd, const char* msg, size_t msglen) {
char header[9];
if (msglen > 0xffff)
@@ -337,6 +338,7 @@ static void send_msg_with_okay(int fd, const char* msg, size_t msglen) {
writex(fd, header, 8);
writex(fd, msg, msglen);
}
+#endif // ADB_HOST
static void send_connect(atransport *t)
{
@@ -414,6 +416,7 @@ void adb_auth_verified(atransport *t)
send_connect(t);
}
+#if ADB_HOST
static char *connection_state_name(atransport *t)
{
if (t == NULL) {
@@ -437,6 +440,7 @@ static char *connection_state_name(atransport *t)
return "unknown";
}
}
+#endif // ADB_HOST
/* qual_overwrite is used to overwrite a qualifier string. dst is a
* pointer to a char pointer. It is assumed that if *dst is non-NULL, it
@@ -1554,8 +1558,6 @@ int handle_forward_request(const char* service, transport_type ttype, char* seri
int handle_host_request(char *service, transport_type ttype, char* serial, int reply_fd, asocket *s)
{
- atransport *transport = NULL;
-
if(!strcmp(service, "kill")) {
fprintf(stderr,"adb server killed by remote request\n");
fflush(stdout);
@@ -1565,6 +1567,7 @@ int handle_host_request(char *service, transport_type ttype, char* serial, int r
}
#if ADB_HOST
+ atransport *transport = NULL;
// "transport:" is used for switching transport with a specified serial number
// "transport-usb:" is used for switching transport to the only USB transport
// "transport-local:" is used for switching transport to the only local transport
diff --git a/adb/adb_auth_host.c b/adb/adb_auth_host.c
index 783774a..c72fe42 100644
--- a/adb/adb_auth_host.c
+++ b/adb/adb_auth_host.c
@@ -45,6 +45,10 @@
#include <openssl/rsa.h>
#include <openssl/sha.h>
+#if defined(OPENSSL_IS_BORINGSSL)
+#include <openssl/base64.h>
+#endif
+
#define TRACE_TAG TRACE_AUTH
#define ANDROID_PATH ".android"
@@ -132,43 +136,67 @@ static void get_user_info(char *buf, size_t len)
static int write_public_keyfile(RSA *private_key, const char *private_key_path)
{
RSAPublicKey pkey;
- BIO *bio, *b64, *bfile;
+ FILE *outfile = NULL;
char path[PATH_MAX], info[MAX_PAYLOAD];
- int ret;
+ uint8_t *encoded = NULL;
+ size_t encoded_length;
+ int ret = 0;
- ret = snprintf(path, sizeof(path), "%s.pub", private_key_path);
- if (ret >= (signed)sizeof(path))
+ if (snprintf(path, sizeof(path), "%s.pub", private_key_path) >=
+ (int)sizeof(path)) {
+ D("Path too long while writing public key\n");
return 0;
+ }
- ret = RSA_to_RSAPublicKey(private_key, &pkey);
- if (!ret) {
+ if (!RSA_to_RSAPublicKey(private_key, &pkey)) {
D("Failed to convert to publickey\n");
return 0;
}
- bfile = BIO_new_file(path, "w");
- if (!bfile) {
+ outfile = fopen(path, "w");
+ if (!outfile) {
D("Failed to open '%s'\n", path);
return 0;
}
D("Writing public key to '%s'\n", path);
- b64 = BIO_new(BIO_f_base64());
- BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
+#if defined(OPENSSL_IS_BORINGSSL)
+ if (!EVP_EncodedLength(&encoded_length, sizeof(pkey))) {
+ D("Public key too large to base64 encode");
+ goto out;
+ }
+#else
+ /* While we switch from OpenSSL to BoringSSL we have to implement
+ * |EVP_EncodedLength| here. */
+ encoded_length = 1 + ((sizeof(pkey) + 2) / 3 * 4);
+#endif
- bio = BIO_push(b64, bfile);
- BIO_write(bio, &pkey, sizeof(pkey));
- (void) BIO_flush(bio);
- BIO_pop(b64);
- BIO_free(b64);
+ encoded = malloc(encoded_length);
+ if (encoded == NULL) {
+ D("Allocation failure");
+ goto out;
+ }
+ encoded_length = EVP_EncodeBlock(encoded, (uint8_t*) &pkey, sizeof(pkey));
get_user_info(info, sizeof(info));
- BIO_write(bfile, info, strlen(info));
- (void) BIO_flush(bfile);
- BIO_free_all(bfile);
- return 1;
+ if (fwrite(encoded, encoded_length, 1, outfile) != 1 ||
+ fwrite(info, strlen(info), 1, outfile) != 1) {
+ D("Write error while writing public key");
+ goto out;
+ }
+
+ ret = 1;
+
+ out:
+ if (outfile != NULL) {
+ fclose(outfile);
+ }
+ if (encoded != NULL) {
+ free(encoded);
+ }
+ return ret;
}
static int generate_key(const char *file)
diff --git a/adb/usb_osx.c b/adb/usb_osx.c
index ca4f2af..ee893f5 100644
--- a/adb/usb_osx.c
+++ b/adb/usb_osx.c
@@ -197,7 +197,8 @@ AndroidInterfaceAdded(void *refCon, io_iterator_t iterator)
kr = (*dev)->GetDeviceProduct(dev, &product);
kr = (*dev)->GetLocationID(dev, &locationId);
if (kr == 0) {
- snprintf(devpathBuf, sizeof(devpathBuf), "usb:%lX", locationId);
+ snprintf(devpathBuf, sizeof(devpathBuf), "usb:%" PRIu32 "X",
+ (unsigned int)locationId);
devpath = devpathBuf;
}
kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex);
diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c
index 957e5db..1b8310f 100755
--- a/adb/usb_vendors.c
+++ b/adb/usb_vendors.c
@@ -38,6 +38,8 @@
/* Keep the list below sorted alphabetically by #define name */
// Acer's USB Vendor ID
#define VENDOR_ID_ACER 0x0502
+// Alco's USB Vendor ID
+#define VENDOR_ID_ALCO 0x1914
// Allwinner's USB Vendor ID
#define VENDOR_ID_ALLWINNER 0x1F3A
// Amlogic's USB Vendor ID
@@ -118,6 +120,8 @@
#define VENDOR_ID_LGE 0x1004
// Lumigon's USB Vendor ID
#define VENDOR_ID_LUMIGON 0x25E3
+// Micromax's USB Vendor ID
+#define VENDOR_ID_MICROMAX 0x2A96
// Motorola's USB Vendor ID
#define VENDOR_ID_MOTOROLA 0x22b8
// MSI's USB Vendor ID
@@ -164,6 +168,8 @@
#define VENDOR_ID_SK_TELESYS 0x1F53
// Smartisan's USB Vendor ID
#define VENDOR_ID_SMARTISAN 0x29a9
+// Sonim Tech's USB Vendor ID
+#define VENDOR_ID_SONIM_TECH 0x1d9c
// Sony's USB Vendor ID
#define VENDOR_ID_SONY 0x054C
// Sony Ericsson's USB Vendor ID
@@ -198,6 +204,7 @@
/* Keep the list below sorted alphabetically */
int builtInVendorIds[] = {
VENDOR_ID_ACER,
+ VENDOR_ID_ALCO,
VENDOR_ID_ALLWINNER,
VENDOR_ID_AMLOGIC,
VENDOR_ID_ANYDATA,
@@ -238,6 +245,7 @@ int builtInVendorIds[] = {
VENDOR_ID_LENOVOMOBILE,
VENDOR_ID_LGE,
VENDOR_ID_LUMIGON,
+ VENDOR_ID_MICROMAX,
VENDOR_ID_MOTOROLA,
VENDOR_ID_MSI,
VENDOR_ID_MTK,
@@ -261,6 +269,7 @@ int builtInVendorIds[] = {
VENDOR_ID_SHARP,
VENDOR_ID_SK_TELESYS,
VENDOR_ID_SMARTISAN,
+ VENDOR_ID_SONIM_TECH,
VENDOR_ID_SONY,
VENDOR_ID_SONY_ERICSSON,
VENDOR_ID_T_AND_A,