diff options
author | Nikias Bassen | 2013-12-11 03:05:19 +0100 |
---|---|---|
committer | Nikias Bassen | 2013-12-11 03:05:19 +0100 |
commit | 4c9a8a7268d51c657d1b9b5b8334298bd6d62c9a (patch) | |
tree | e4994975a42ccc38bda9861d3be96e097208be85 /src | |
parent | edc385ef6a78faa2a4bd8d37d80d88986544442f (diff) | |
download | usbmuxd-4c9a8a7268d51c657d1b9b5b8334298bd6d62c9a.tar.gz usbmuxd-4c9a8a7268d51c657d1b9b5b8334298bd6d62c9a.tar.bz2 |
client: return proper error packet on client version mismatch
Diffstat (limited to 'src')
-rw-r--r-- | src/client.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/client.c b/src/client.c index c8fb470..ac5d08e 100644 --- a/src/client.c +++ b/src/client.c @@ -42,11 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" #include "device.h" -#ifdef HAVE_PLIST #define CMD_BUF_SIZE 1024 -#else -#define CMD_BUF_SIZE 256 -#endif #define REPLY_BUF_SIZE 1024 enum client_state { @@ -387,6 +383,17 @@ static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) return -1; } +#ifdef HAVE_PLIST + if((hdr->version != 0) && (hdr->version != 1)) { + usbmuxd_log(LL_INFO, "Client %d version mismatch: expected 0 or 1, got %d", client->fd, hdr->version); +#else + if(hdr->version != USBMUXD_PROTOCOL_VERSION) { + usbmuxd_log(LL_INFO, "Client %d version mismatch: expected %d, got %d", client->fd, USBMUXD_PROTOCOL_VERSION, hdr->version); +#endif + send_result(client, hdr->tag, RESULT_BADVERSION); + return 0; + } + struct usbmuxd_connect_request *ch; #ifdef HAVE_PLIST char *payload; @@ -557,16 +564,6 @@ static void process_recv(struct mux_client *client) did_read = 1; } struct usbmuxd_header *hdr = (void*)client->ib_buf; -#ifdef HAVE_PLIST - if((hdr->version != 0) && (hdr->version != 1)) { - usbmuxd_log(LL_INFO, "Client %d version mismatch: expected 0 or 1, got %d", client->fd, hdr->version); -#else - if(hdr->version != USBMUXD_PROTOCOL_VERSION) { - usbmuxd_log(LL_INFO, "Client %d version mismatch: expected %d, got %d", client->fd, USBMUXD_PROTOCOL_VERSION, hdr->version); -#endif - client_close(client); - return; - } if(hdr->length > client->ib_capacity) { usbmuxd_log(LL_INFO, "Client %d message is too long (%d bytes)", client->fd, hdr->length); client_close(client); |