aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2017-12-20 10:41:25 +0100
committerToni Uhlig <matzeton@googlemail.com>2017-12-20 10:41:25 +0100
commitd76db8ec11a0cc6b95e9758cc912efbfdba175da (patch)
treea16692e856bf323d223079882b1fbf3c248b2c1b /src
parentdbfa491594e0c84079bebc991107e1b51a228433 (diff)
ptunnel-ng:
* do not break strict aliasing
Diffstat (limited to 'src')
-rw-r--r--src/pkt.c4
-rw-r--r--src/ptunnel.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/pkt.c b/src/pkt.c
index 9bd8777..725a14c 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -25,6 +25,7 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a
uint32_t type_flag, pkt_flag, init_state, proxy_flag;
challenge_t *challenge;
struct timeval tt;
+ struct in_addr in_addr;
proxy_flag = kProxy_flag;
@@ -102,8 +103,9 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a
pt_log(kLog_verbose, "Dropping request: ID was recently in use.\n");
return;
}
+ in_addr.s_addr = pt_pkt->dst_ip;
pt_log(kLog_info, "Starting new session to %s:%d with ID %d\n",
- inet_ntoa(*(struct in_addr *)&pt_pkt->dst_ip),
+ inet_ntoa(in_addr),
ntohl(pt_pkt->dst_port), pt_pkt->id_no);
if ((opts.given_dst_ip && opts.given_dst_ip != pt_pkt->dst_ip) ||
((uint32_t)-1 != opts.given_dst_port && opts.given_dst_port != ntohl(pt_pkt->dst_port)))
diff --git a/src/ptunnel.c b/src/ptunnel.c
index 927d440..32bc4df 100644
--- a/src/ptunnel.c
+++ b/src/ptunnel.c
@@ -251,6 +251,7 @@ void pt_forwarder(void) {
socklen_t addr_len;
pthread_t pid;
uint16_t rand_id;
+ struct in_addr in_addr;
pt_log(kLog_debug, "Starting forwarder..\n");
/** Open our listening socket */
@@ -277,8 +278,9 @@ void pt_forwarder(void) {
dest_addr.sin_port = htons(kDNS_port /* dns port.. */);
else
dest_addr.sin_port = 0;
+ in_addr.s_addr = opts.given_proxy_ip;
dest_addr.sin_addr.s_addr = opts.given_proxy_ip;
- pt_log(kLog_verbose, "Proxy IP address: %s\n", inet_ntoa(*((struct in_addr*)&opts.given_proxy_ip)));
+ pt_log(kLog_verbose, "Proxy IP address: %s\n", inet_ntoa(in_addr));
listen(server_sock, 10);
while (1) {
@@ -373,6 +375,7 @@ void* pt_proxy(void *args) {
uint32_t ip;
in_addr_t *adr;
#endif
+ struct in_addr in_addr;
/* Start the thread, initialize protocol and ring states. */
pt_log(kLog_debug, "Starting ping proxy..\n");
@@ -577,8 +580,9 @@ void* pt_proxy(void *args) {
pthread_mutex_lock(&chain_lock);
now = time_as_double();
for (cur = chain; cur; cur = cur->next) {
+ in_addr.s_addr = cur->dst_ip;
if (cur->last_activity + kAutomatic_close_timeout < now) {
- pt_log(kLog_info, "Dropping tunnel to %s:%d due to inactivity.\n", inet_ntoa(*(struct in_addr*)&cur->dst_ip), cur->dst_port, cur->id_no);
+ pt_log(kLog_info, "Dropping tunnel to %s:%d due to inactivity.\n", inet_ntoa(in_addr), cur->dst_port, cur->id_no);
cur->should_remove = 1;
continue;
}