From d1c216b79080ac6092c362504bcc44f5d4b929c4 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 23 Dec 2018 13:56:39 +0100 Subject: improved error logging Signed-off-by: Toni Uhlig --- src/pkt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/pkt.c') diff --git a/src/pkt.c b/src/pkt.c index 869cf51..bc85bc7 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -189,7 +189,9 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a return; } else - pt_log(kLog_error, "Dropping duplicate proxy session request.\n"); + pt_log(kLog_error, "Dropping duplicate proxy session request " + "with ID %d and seq %d.\n", + pt_pkt->id_no, pt_pkt->seq_no); } else if (cur && pt_pkt->state == kProto_authenticate) { /* Sanity check packet length, and make sure it matches what we expect */ -- cgit v1.2.3 From d9d7a33d2e2f1627845001b98152cd05b5781ab3 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 8 Jan 2019 09:43:33 +0100 Subject: copyright update Signed-off-by: Toni Uhlig --- COPYING | 2 +- README | 2 +- README.md | 2 +- debian/copyright | 2 +- src/challenge.c | 2 +- src/challenge.h | 2 +- src/options.c | 2 +- src/options.h | 2 +- src/pconfig.h | 2 +- src/pdesc.c | 2 +- src/pdesc.h | 2 +- src/pkt.c | 2 +- src/pkt.h | 2 +- src/ptunnel.c | 4 ++-- src/utils.c | 2 +- src/utils.h | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/pkt.c') diff --git a/COPYING b/COPYING index 8b4cb53..6918db2 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright (c) 2017, Toni Uhlig +Copyright (c) 2017-2019, Toni Uhlig All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README b/README index 97cd0d0..1a0712e 100644 --- a/README +++ b/README @@ -128,6 +128,6 @@ Daniel Stoedle et al. License ------- -Ping Tunnel NG is Copyright (c) 2017, Toni Uhlig , +Ping Tunnel NG is Copyright (c) 2017-2019, Toni Uhlig , All rights reserved. Ping Tunnel NG is licensed under the BSD License. Please see the COPYING file for details. diff --git a/README.md b/README.md index 34c00c1..5d48190 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ Daniel Stoedle et al. ## License ``` -Ping Tunnel NG is Copyright (c) 2017, Toni Uhlig , +Ping Tunnel NG is Copyright (c) 2017-2019, Toni Uhlig , All rights reserved. Ping Tunnel NG is licensed under the BSD License. Please see the COPYING file for details. ``` diff --git a/debian/copyright b/debian/copyright index b0e21c4..855cf53 100644 --- a/debian/copyright +++ b/debian/copyright @@ -3,7 +3,7 @@ Upstream-Name: ptunnel Source: http://www.cs.uit.no/~daniels/PingTunnel/index.html Files: * -Copyright: Copyright 2017 Toni Uhlig +Copyright: Copyright 2017-2019 Toni Uhlig License: BSD-3-Clause Files: md5.* diff --git a/src/challenge.c b/src/challenge.c index 4f69298..f269313 100644 --- a/src/challenge.c +++ b/src/challenge.c @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/challenge.h b/src/challenge.h index 035a97e..18495cf 100644 --- a/src/challenge.h +++ b/src/challenge.h @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/options.c b/src/options.c index beecd39..4ae434f 100644 --- a/src/options.c +++ b/src/options.c @@ -2,7 +2,7 @@ * options.c * ptunnel is licensed under the BSD license: * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/options.h b/src/options.h index 3c42a19..176620a 100644 --- a/src/options.h +++ b/src/options.h @@ -2,7 +2,7 @@ * options.h * ptunnel is licensed under the BSD license: * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/pconfig.h b/src/pconfig.h index c85df14..6be141e 100644 --- a/src/pconfig.h +++ b/src/pconfig.h @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/pdesc.c b/src/pdesc.c index 906f35c..5ba2003 100644 --- a/src/pdesc.c +++ b/src/pdesc.c @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/pdesc.h b/src/pdesc.h index 35147db..d0767aa 100644 --- a/src/pdesc.h +++ b/src/pdesc.h @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/pkt.c b/src/pkt.c index bc85bc7..06dfd91 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/pkt.h b/src/pkt.h index 9668d97..338bc65 100644 --- a/src/pkt.h +++ b/src/pkt.h @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/ptunnel.c b/src/ptunnel.c index aa50883..8fdf7a8 100644 --- a/src/ptunnel.c +++ b/src/ptunnel.c @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -150,7 +150,7 @@ int main(int argc, char *argv[]) { #endif pt_log(kLog_info, "Starting %s.\n", PACKAGE_STRING); pt_log(kLog_info, "(c) 2004-2011 Daniel Stoedle, \n"); - pt_log(kLog_info, "(c) 2017 Toni Uhlig, \n"); + pt_log(kLog_info, "(c) 2017-2019 Toni Uhlig, \n"); #ifdef WIN32 pt_log(kLog_info, "Windows version by Mike Miller, \n"); #else diff --git a/src/utils.c b/src/utils.c index 10e8182..462d688 100644 --- a/src/utils.c +++ b/src/utils.c @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/utils.h b/src/utils.h index 1ad2416..0796848 100644 --- a/src/utils.h +++ b/src/utils.h @@ -5,7 +5,7 @@ * Copyright (c) 2004-2011, Daniel Stoedle , * Yellow Lemon Software. All rights reserved. * - * Copyright (c) 2017 Toni Uhlig + * Copyright (c) 2017-2019, Toni Uhlig * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: -- cgit v1.2.3 From bf54c7ed64a17693762a9db4fbaa3765d182a501 Mon Sep 17 00:00:00 2001 From: elnerd Date: Wed, 16 Jan 2019 20:40:58 +0100 Subject: fixed some bugs that can lead to remove segfaults --- src/pdesc.c | 2 +- src/pkt.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/pkt.c') diff --git a/src/pdesc.c b/src/pdesc.c index 5ba2003..51fa3ab 100644 --- a/src/pdesc.c +++ b/src/pdesc.c @@ -56,7 +56,7 @@ * the descriptor chain. If the sock argument is 0, the function will establish * a TCP connection to the ip and port given by dst_ip, dst_port. */ -proxy_desc_t* create_and_insert_proxy_desc(uint16_t id_no, uint16_t icmp_id, +proxy_desc_t *create_and_insert_proxy_desc(uint16_t id_no, uint16_t icmp_id, int sock, struct sockaddr_in *addr, uint32_t dst_ip, uint32_t dst_port, uint32_t init_state, uint32_t type) { diff --git a/src/pkt.c b/src/pkt.c index 06dfd91..9ba2181 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -124,6 +124,10 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a pkt_flag = pt_pkt->state & kFlag_mask; pt_pkt->state &= ~kFlag_mask; + if (pt_pkt->state > (kNum_proto_types-1)) { + pt_log(kLog_error, "Dropping packet with invalid state.\n"); + return; + } pt_log(kLog_sendrecv, "Recv: %d [%d] bytes " "[seq = %d] [type = %s] " "[ack = %d] [icmp = %d] " @@ -166,14 +170,20 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a else init_state = kProto_data; - cur = create_and_insert_proxy_desc(pt_pkt->id_no, pkt->identifier, 0, + cur = (proxy_desc_t*) create_and_insert_proxy_desc(pt_pkt->id_no, pkt->identifier, 0, addr, pt_pkt->dst_ip, ntohl(pt_pkt->dst_port), init_state, kProxy_flag); + if (!cur) { + /* if failed, abort. Logging is done in create_insert_proxy_desc */ + pt_log(kLog_info, "failed to create proxy descriptor\n"); + return; + } if (init_state == kProto_authenticate) { pt_log(kLog_debug, "Sending authentication challenge..\n"); /* Send challenge */ cur->challenge = generate_challenge(); + pt_log(kLog_debug, "Challenge generated\n"); memcpy(cur->buf, cur->challenge, sizeof(challenge_t)); queue_packet(icmp_sock, cur->pkt_type, cur->buf, sizeof(challenge_t), cur->id_no, -- cgit v1.2.3 From 5850d4218e7199c80499217a6f9faeb967f69c08 Mon Sep 17 00:00:00 2001 From: dev0 Date: Wed, 16 Jan 2019 23:13:47 +0100 Subject: cosmetics ty very much @elnerd --- src/pkt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/pkt.c') diff --git a/src/pkt.c b/src/pkt.c index 9ba2181..d446ffd 100644 --- a/src/pkt.c +++ b/src/pkt.c @@ -170,20 +170,19 @@ void handle_packet(char *buf, unsigned bytes, int is_pcap, struct sockaddr_in *a else init_state = kProto_data; - cur = (proxy_desc_t*) create_and_insert_proxy_desc(pt_pkt->id_no, pkt->identifier, 0, + cur = (proxy_desc_t *) create_and_insert_proxy_desc(pt_pkt->id_no, pkt->identifier, 0, addr, pt_pkt->dst_ip, ntohl(pt_pkt->dst_port), init_state, kProxy_flag); if (!cur) { /* if failed, abort. Logging is done in create_insert_proxy_desc */ - pt_log(kLog_info, "failed to create proxy descriptor\n"); + pt_log(kLog_error, "Failed to create proxy descriptor!\n"); return; } if (init_state == kProto_authenticate) { pt_log(kLog_debug, "Sending authentication challenge..\n"); /* Send challenge */ cur->challenge = generate_challenge(); - pt_log(kLog_debug, "Challenge generated\n"); memcpy(cur->buf, cur->challenge, sizeof(challenge_t)); queue_packet(icmp_sock, cur->pkt_type, cur->buf, sizeof(challenge_t), cur->id_no, -- cgit v1.2.3