X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprotocol_auth.c;h=057b88e545939e2b27c6946567768ee54f968807;hb=58007d7efa3940c863c5a398f8b257a686ce37ba;hp=d3eef21e0eb4c2cc8903446ba5bcd2a89666c14f;hpb=8ac096b5bf9da1b3961a3ac4a03d083629222a63;p=tinc diff --git a/src/protocol_auth.c b/src/protocol_auth.c index d3eef21e..057b88e5 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -1,7 +1,7 @@ /* protocol_auth.c -- handle the meta-protocol, authentication Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2010 Guus Sliepen + 2000-2012 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 @@ -57,7 +57,7 @@ bool send_id(connection_t *c) { return send_request(c, "%d %s %d.%d", ID, myself->connection->name, myself->connection->protocol_major, minor); } -bool id_h(connection_t *c, char *request) { +bool id_h(connection_t *c, const char *request) { char name[MAX_STRING_SIZE]; if(sscanf(request, "%*d " MAX_STRING " %d.%d", name, &c->protocol_major, &c->protocol_minor) < 2) { @@ -72,6 +72,10 @@ bool id_h(connection_t *c, char *request) { c->status.control = true; c->allow_request = CONTROL; c->last_ping_time = time(NULL) + 3600; + + free(c->name); + c->name = xstrdup(""); + return send_request(c, "%d %d %d", ACK, TINC_CTL_VERSION_CURRENT, getpid()); } @@ -144,7 +148,7 @@ bool id_h(connection_t *c, char *request) { else snprintf(label, sizeof label, "tinc TCP key expansion %s %s", c->name, myself->name); - return sptps_start(&c->sptps, c, c->outgoing, myself->connection->ecdsa, c->ecdsa, label, sizeof label, send_meta_sptps, receive_meta_sptps); + return sptps_start(&c->sptps, c, c->outgoing, false, myself->connection->ecdsa, c->ecdsa, label, sizeof label, send_meta_sptps, receive_meta_sptps); } else { return send_metakey(c); } @@ -215,7 +219,7 @@ bool send_metakey(connection_t *c) { return result; } -bool metakey_h(connection_t *c, char *request) { +bool metakey_h(connection_t *c, const char *request) { char hexkey[MAX_STRING_SIZE]; int cipher, digest, maclength, compression; size_t len = rsa_size(&myself->connection->rsa); @@ -289,7 +293,7 @@ bool send_challenge(connection_t *c) { return send_request(c, "%d %s", CHALLENGE, buffer); } -bool challenge_h(connection_t *c, char *request) { +bool challenge_h(connection_t *c, const char *request) { char buffer[MAX_STRING_SIZE]; size_t len = rsa_size(&myself->connection->rsa); size_t digestlen = digest_length(&c->indigest); @@ -326,7 +330,7 @@ bool challenge_h(connection_t *c, char *request) { return send_request(c, "%d %s", CHAL_REPLY, buffer); } -bool chal_reply_h(connection_t *c, char *request) { +bool chal_reply_h(connection_t *c, const char *request) { char hishash[MAX_STRING_SIZE]; if(sscanf(request, "%*d " MAX_STRING, hishash) != 1) { @@ -447,7 +451,7 @@ static void send_everything(connection_t *c) { } } -static bool upgrade_h(connection_t *c, char *request) { +static bool upgrade_h(connection_t *c, const char *request) { char pubkey[MAX_STRING_SIZE]; if(sscanf(request, "%*d " MAX_STRING, pubkey) != 1) { @@ -466,7 +470,7 @@ static bool upgrade_h(connection_t *c, char *request) { return send_termreq(c); } -bool ack_h(connection_t *c, char *request) { +bool ack_h(connection_t *c, const char *request) { if(c->protocol_minor == 1) return upgrade_h(c, request);