X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprotocol_misc.c;h=b68179dc36f050510ec8dd2d012b6540e81e42e0;hb=c8402791b82947c49ba1d04f855dab04191607ca;hp=088a5242b97bf4a54c22ff68fe545cf6825611f2;hpb=6debc6c79ba385d35f646e0958f84ace5b8f4b4d;p=tinc diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 088a5242..b68179dc 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -1,7 +1,7 @@ /* protocol_misc.c -- handle the meta-protocol, miscellaneous functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen + 2000-2022 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -68,15 +68,16 @@ bool pong_h(connection_t *c, const char *request) { if(c->outgoing && c->outgoing->timeout) { c->outgoing->timeout = 0; - reset_address_cache(c->outgoing->node->address_cache, &c->address); + reset_address_cache(c->node->address_cache); + add_recent_address(c->node->address_cache, &c->address); } return true; } static bool random_early_drop(connection_t *c) { - if(c->outbuf.len > maxoutbufsize / 2) { - if((c->outbuf.len - maxoutbufsize / 2) > prng((maxoutbufsize) / 2)) { + if(c->outbuf.len > (size_t)maxoutbufsize / 2) { + if((c->outbuf.len - (size_t)maxoutbufsize / 2) > prng((size_t)maxoutbufsize / 2)) { return true; } } @@ -104,7 +105,7 @@ bool send_tcppacket(connection_t *c, const vpn_packet_t *packet) { bool tcppacket_h(connection_t *c, const char *request) { short int len; - if(sscanf(request, "%*d %hd", &len) != 1) { + if(sscanf(request, "%*d %hd", &len) != 1 || len < 0) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "PACKET", c->name, c->hostname); return false; @@ -125,7 +126,7 @@ bool send_sptps_tcppacket(connection_t *c, const void *packet, size_t len) { return true; } - if(!send_request(c, "%d %zu", SPTPS_PACKET, len)) { + if(!send_request(c, "%d %lu", SPTPS_PACKET, (unsigned long)len)) { return false; } @@ -136,7 +137,7 @@ bool send_sptps_tcppacket(connection_t *c, const void *packet, size_t len) { bool sptps_tcppacket_h(connection_t *c, const char *request) { short int len; - if(sscanf(request, "%*d %hd", &len) != 1) { + if(sscanf(request, "%*d %hd", &len) != 1 || len < 0) { logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "SPTPS_PACKET", c->name, c->hostname); return false;