Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 578a5649 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "adb: disable checksum on new versions"

parents eef035f6 de471949
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -240,7 +240,10 @@ void send_connect(atransport* t) {
    D("Calling send_connect");
    apacket* cp = get_apacket();
    cp->msg.command = A_CNXN;
    cp->msg.arg0 = t->get_protocol_version();
    // Send the max supported version, but because the transport is
    // initialized to A_VERSION_MIN, this will be compatible with every
    // device.
    cp->msg.arg0 = A_VERSION;
    cp->msg.arg1 = t->get_max_payload();

    std::string connection_str = get_connection_string();
+7 −2
Original line number Diff line number Diff line
@@ -44,7 +44,12 @@ constexpr size_t LINUX_MAX_SOCKET_SIZE = 4194304;
#define A_AUTH 0x48545541

// ADB protocol version.
#define A_VERSION 0x01000000
// Version revision:
// 0x01000000: original
// 0x01000001: skip checksum (Dec 2017)
#define A_VERSION_MIN 0x01000000
#define A_VERSION_SKIP_CHECKSUM 0x01000001
#define A_VERSION 0x01000001

// Used for help/version information.
#define ADB_VERSION_MAJOR 1
@@ -53,7 +58,7 @@ constexpr size_t LINUX_MAX_SOCKET_SIZE = 4194304;
std::string adb_version();

// Increment this when we want to force users to start a new adb server.
#define ADB_SERVER_VERSION 39
#define ADB_SERVER_VERSION 40

using TransportId = uint64_t;
class atransport;
+6 −5
Original line number Diff line number Diff line
@@ -163,7 +163,12 @@ static void transport_socket_events(int fd, unsigned events, void* _t) {

void send_packet(apacket* p, atransport* t) {
    p->msg.magic = p->msg.command ^ 0xffffffff;
    // compute a checksum for connection/auth packets for compatibility reasons
    if (t->get_protocol_version() >= A_VERSION_SKIP_CHECKSUM) {
        p->msg.data_check = 0;
    } else {
        p->msg.data_check = calculate_apacket_checksum(p);
    }

    print_packet("send", p);

@@ -1089,10 +1094,6 @@ bool check_header(apacket* p, atransport* t) {
    return true;
}

bool check_data(apacket* p) {
    return calculate_apacket_checksum(p) == p->msg.data_check;
}

#if ADB_HOST
std::shared_ptr<RSA> atransport::NextKey() {
    if (keys_.empty()) keys_ = adb_auth_get_private_keys();
+3 −2
Original line number Diff line number Diff line
@@ -66,7 +66,9 @@ class atransport {
    atransport(ConnectionState state = kCsOffline)
        : id(NextTransportId()), connection_state_(state) {
        transport_fde = {};
        protocol_version = A_VERSION;
        // Initialize protocol to min version for compatibility with older versions.
        // Version will be updated post-connect.
        protocol_version = A_VERSION_MIN;
        max_payload = MAX_PAYLOAD;
    }
    virtual ~atransport() {}
@@ -223,7 +225,6 @@ int register_socket_transport(int s, const char* serial, int port, int local);
void unregister_usb_transport(usb_handle* usb);

bool check_header(apacket* p, atransport* t);
bool check_data(apacket* p);

void close_usb_devices();
void close_usb_devices(std::function<bool(const atransport*)> predicate);
+0 −5
Original line number Diff line number Diff line
@@ -77,11 +77,6 @@ static int remote_read(apacket *p, atransport *t)
        return -1;
    }

    if (!check_data(p)) {
        D("bad data: terminated (data)");
        return -1;
    }

    return 0;
}

Loading