X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsptps.c;h=780014008a94a6983ab41618f746b7306ce51d5f;hb=b234304b6628aeddce63d7f751da97c3344bbb78;hp=10d6e047f78f5d02c52087c354dad710fe05160a;hpb=5d0812d49275ec8bda2b5b0ac813239045463777;p=tinc diff --git a/src/sptps.c b/src/sptps.c index 10d6e047..78001400 100644 --- a/src/sptps.c +++ b/src/sptps.c @@ -436,7 +436,7 @@ static bool sptps_receive_data_datagram(sptps_t *s, const char *data, size_t len } else if (seqno < s->inseqno) { // If the sequence number is farther in the past than the bitmap goes, or if the packet was already received, drop it. if((s->inseqno >= s->replaywin * 8 && seqno < s->inseqno - s->replaywin * 8) || !(s->late[(seqno / 8) % s->replaywin] & (1 << seqno % 8))) { - fprintf(stderr, "Received late or replayed packet, seqno %d, last received %d", seqno, s->inseqno); + fprintf(stderr, "Received late or replayed packet, seqno %d, last received %d\n", seqno, s->inseqno); return false; } } else { @@ -508,7 +508,7 @@ bool sptps_receive_data(sptps_t *s, const char *data, size_t len) { s->buflen += toread; len -= toread; data += toread; - + // Exit early if we don't have the full length. if(s->buflen < 6) return true; @@ -627,18 +627,17 @@ bool sptps_start(sptps_t *s, void *handle, bool initiator, bool datagram, ecdsa_ // Stop a SPTPS session. bool sptps_stop(sptps_t *s) { // Clean up any resources. + cipher_close(&s->incipher); + cipher_close(&s->outcipher); + digest_close(&s->indigest); + digest_close(&s->outdigest); ecdh_free(&s->ecdh); free(s->inbuf); - s->inbuf = NULL; free(s->mykex); - s->mykex = NULL; free(s->hiskex); - s->hiskex = NULL; free(s->key); - s->key = NULL; free(s->label); - s->label = NULL; free(s->late); - s->late = NULL; + memset(s, 0, sizeof *s); return true; }