Skip to content

Commit

Permalink
Make conn_data member of usbmuxd_device_info struct unsigned since it…
Browse files Browse the repository at this point in the history
…'s not a string

Also remove some pointless casts and update some others
  • Loading branch information
nikias committed May 4, 2022
1 parent a9a639d commit 36ffb7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/usbmuxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ typedef struct {
uint32_t product_id;
char udid[44];
enum usbmux_connection_type conn_type;
char conn_data[200];
uint8_t conn_data[200];
} usbmuxd_device_info_t;

/**
Expand Down
10 changes: 5 additions & 5 deletions tools/inetcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,22 @@ int main(int argc, char **argv)
unsigned char saddr_[32];
memset(saddr_, '\0', sizeof(saddr_));
struct sockaddr* saddr = (struct sockaddr*)&saddr_[0];
if (((char*)dev->conn_data)[1] == 0x02) { // AF_INET
if (dev->conn_data[1] == 0x02) { // AF_INET
saddr->sa_family = AF_INET;
memcpy(&saddr->sa_data[0], (char*)dev->conn_data+2, 14);
memcpy(&saddr->sa_data[0], (uint8_t*)dev->conn_data+2, 14);
}
else if (((char*)dev->conn_data)[1] == 0x1E) { //AF_INET6 (bsd)
else if (dev->conn_data[1] == 0x1E) { //AF_INET6 (bsd)
#ifdef AF_INET6
saddr->sa_family = AF_INET6;
memcpy(&saddr->sa_data[0], (char*)dev->conn_data+2, 26);
memcpy(&saddr->sa_data[0], (uint8_t*)dev->conn_data+2, 26);
#else
fprintf(stderr, "ERROR: Got an IPv6 address but this system doesn't support IPv6\n");
free(dev_list);
return 1;
#endif
}
else {
fprintf(stderr, "Unsupported address family 0x%02x\n", ((char*)dev->conn_data)[1]);
fprintf(stderr, "Unsupported address family 0x%02x\n", dev->conn_data[1]);
free(dev_list);
return 1;
}
Expand Down
10 changes: 5 additions & 5 deletions tools/iproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,23 @@ static void *acceptor_thread(void *arg)
struct sockaddr_storage saddr_storage;
struct sockaddr* saddr = (struct sockaddr*)&saddr_storage;

if (((char*)dev->conn_data)[1] == 0x02) { // AF_INET
if (dev->conn_data[1] == 0x02) { // AF_INET
saddr->sa_family = AF_INET;
memcpy(&saddr->sa_data[0], (char*)dev->conn_data + 2, 14);
memcpy(&saddr->sa_data[0], (uint8_t*)dev->conn_data+2, 14);
}
else if (((char*)dev->conn_data)[1] == 0x1E) { //AF_INET6 (bsd)
else if (dev->conn_data[1] == 0x1E) { //AF_INET6 (bsd)
#ifdef AF_INET6
saddr->sa_family = AF_INET6;
/* copy the address and the host dependent scope id */
memcpy(&saddr->sa_data[0], (char*)dev->conn_data + 2, 26);
memcpy(&saddr->sa_data[0], (uint8_t*)dev->conn_data+2, 26);
#else
fprintf(stderr, "ERROR: Got an IPv6 address but this system doesn't support IPv6\n");
CDATA_FREE(cdata);
return NULL;
#endif
}
else {
fprintf(stderr, "Unsupported address family 0x%02x\n", ((char*)dev->conn_data)[1]);
fprintf(stderr, "Unsupported address family 0x%02x\n", dev->conn_data[1]);
CDATA_FREE(cdata);
return NULL;
}
Expand Down

0 comments on commit 36ffb7a

Please sign in to comment.