From b3b0e345a94830a186168a4ecd53e0259a00b0c0 Mon Sep 17 00:00:00 2001 From: GDR! Date: Wed, 7 Dec 2016 15:26:38 +0100 Subject: [PATCH] Fixed some warnings --- Makefile | 2 +- README.md | 2 +- client.c | 16 +++++++--------- client.h | 2 +- main.c | 2 +- main.h | 3 +++ 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 1c4effd..1226d25 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SOURCES = $(wildcard *.c) DEPS=libsodium toxcore CC=gcc -CFLAGS=-g #-std=c99 +CFLAGS=-g -Wall #-std=c99 CFLAGS += $(shell pkg-config --cflags $(DEPS)) LDFLAGS=-g -pthread -lm -static -lrt LDFLAGS += $(shell pkg-config --static --libs $(DEPS)) diff --git a/README.md b/README.md index cd38142..6007e75 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Client can be ran as a regular non-root user, [unless A < 1024](https://www.linu ## Security / threat model -**TUNTOX IS NOT SECURE WITHOUT THE -s SWITCH.** Supply *-s yourpassword* both on the server and the client, and you will be fine. This switch is introduced in 0.0.4, codename "Mr. Lahey's Got My Porno Tape!". +**TUNTOX IS NOT SECURE WITHOUT THE -s SWITCH.** Supply *-s yourpassword* both on the server and the client, and you will be fine. This switch is introduced in 0.0.4, codename "Mr. Lahey's Got My Porno Tape!". Even better, run `TUNTOX_SHARED_SECRET=yourpassword tuntox ...` on both sides. The Tuntox server generates a new Tox ID on every startup, or saves its private key in a file. Anyone who wants to connect to this server needs its Tox ID, which consists of the publicly-known pubkey and a secret 32-bit "antispam" value. Then, the client sends a shared secret which is then compared to the secred supplied on server's command line. If they don't match, friend request is left unanswered. diff --git a/client.c b/client.c index 0634702..381087c 100644 --- a/client.c +++ b/client.c @@ -37,7 +37,6 @@ int handle_pong_frame(protocol_frame *rcvd_frame) if(ping_mode) { -// state = CLIENT_STATE_PONG_RECEIVED; state = CLIENT_STATE_SEND_PING; } return 0; @@ -198,7 +197,7 @@ int handle_server_tcp_frame(protocol_frame *rcvd_frame) if(sent_bytes < 0) { - char data[PROTOCOL_BUFFER_OFFSET]; + uint8_t data[PROTOCOL_BUFFER_OFFSET]; protocol_frame frame_st, *frame; log_printf(L_INFO, "Could not write to socket %d: %s\n", write_sockfd, strerror(errno)); @@ -231,7 +230,6 @@ int handle_server_tcp_frame(protocol_frame *rcvd_frame) int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame) { tunnel *tun=NULL; - int offset = 0; int connid = rcvd_frame->connid; HASH_FIND_INT(by_id, &connid, tun); @@ -258,7 +256,7 @@ int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame) } /* Main loop for the client */ -int do_client_loop(char *tox_id_str) +int do_client_loop(unsigned char *tox_id_str) { unsigned char tox_packet_buf[PROTOCOL_MAX_PACKET_SIZE]; unsigned char tox_id[TOX_ADDRESS_SIZE]; @@ -273,7 +271,7 @@ int do_client_loop(char *tox_id_str) client_tunnel.sockfd = 0; FD_ZERO(&client_master_fdset); - tox_callback_friend_lossless_packet(tox, parse_lossless_packet, NULL); + tox_callback_friend_lossless_packet(tox, parse_lossless_packet); if(!string_to_id(tox_id, tox_id_str)) { @@ -292,7 +290,7 @@ int do_client_loop(char *tox_id_str) while(1) { /* Let tox do its stuff */ - tox_iterate(tox); + tox_iterate(tox, NULL); switch(state) { @@ -307,15 +305,15 @@ int do_client_loop(char *tox_id_str) break; case CLIENT_STATE_CONNECTED: { - uint8_t* data = "Hi, fellow tuntox instance!"; + uint8_t* data = (uint8_t *)"Hi, fellow tuntox instance!"; uint16_t length = sizeof(data); TOX_ERR_FRIEND_ADD add_error; if(use_shared_secret) { - data = shared_secret; + data = (uint8_t *)shared_secret; data[TOX_MAX_FRIEND_REQUEST_LENGTH-1] = '\0'; - length = strlen(data)+1; + length = strlen((char *)data)+1; log_printf(L_DEBUG, "Sent shared secret of length %u\n", length); } diff --git a/client.h b/client.h index 1ac5008..abba3ab 100644 --- a/client.h +++ b/client.h @@ -18,4 +18,4 @@ int handle_pong_frame(protocol_frame *rcvd_frame); int handle_acktunnel_frame(protocol_frame *rcvd_frame); int handle_server_tcp_frame(protocol_frame *rcvd_frame); int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame); -int do_client_loop(char *tox_id_str); +int do_client_loop(unsigned char *tox_id_str); diff --git a/main.c b/main.c index 783b509..99d9e52 100644 --- a/main.c +++ b/main.c @@ -177,7 +177,7 @@ void set_tox_username(Tox *tox) int gai_result; TOX_ERR_SET_INFO error; - gethostname(hostname, 1024); + gethostname((char*)hostname, 1024); hostname[1023] = '\0'; tox_self_set_name(tox, hostname, strlen(hostname), &error); diff --git a/main.h b/main.h index 329135f..fdffa11 100644 --- a/main.h +++ b/main.h @@ -109,6 +109,9 @@ extern tunnel *by_id; void parse_lossless_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, size_t len, void *tmp); tunnel *tunnel_create(int sockfd, int connid, uint32_t friendnumber); void tunnel_delete(tunnel *t); +void update_select_nfds(int fd); +int send_frame(protocol_frame *frame, uint8_t *data); +int send_tunnel_request_packet(char *remote_host, int remote_port, int friend_number); void print_version(void); #endif