Make sure connection->name is never NULL.

This commit is contained in:
Guus Sliepen 2007-05-16 14:42:08 +00:00
parent f0cf4991e2
commit 480dd127c8
3 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,6 @@
/* /*
connection.c -- connection list management connection.c -- connection list management
Copyright (C) 2000-2006 Guus Sliepen <guus@tinc-vpn.org>, Copyright (C) 2000-2007 Guus Sliepen <guus@tinc-vpn.org>,
2000-2005 Ivo Timmermans 2000-2005 Ivo Timmermans
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -78,6 +78,9 @@ void free_connection(connection_t *c)
{ {
cp(); cp();
if(c->name)
free(c->name);
if(c->hostname) if(c->hostname)
free(c->hostname); free(c->hostname);

View file

@ -1,7 +1,7 @@
/* /*
net_socket.c -- Handle various kinds of sockets. net_socket.c -- Handle various kinds of sockets.
Copyright (C) 1998-2005 Ivo Timmermans, Copyright (C) 1998-2005 Ivo Timmermans,
2000-2006 Guus Sliepen <guus@tinc-vpn.org> 2000-2007 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -424,7 +424,7 @@ bool handle_new_meta_connection(int sock)
sockaddrunmap(&sa); sockaddrunmap(&sa);
c = new_connection(); c = new_connection();
c->name = NULL; c->name = xstrdup("<unknown>");
c->outcipher = myself->connection->outcipher; c->outcipher = myself->connection->outcipher;
c->outdigest = myself->connection->outdigest; c->outdigest = myself->connection->outdigest;
c->outmaclength = myself->connection->outmaclength; c->outmaclength = myself->connection->outmaclength;

View file

@ -1,7 +1,7 @@
/* /*
protocol_auth.c -- handle the meta-protocol, authentication protocol_auth.c -- handle the meta-protocol, authentication
Copyright (C) 1999-2005 Ivo Timmermans, Copyright (C) 1999-2005 Ivo Timmermans,
2000-2006 Guus Sliepen <guus@tinc-vpn.org> 2000-2007 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -68,9 +68,9 @@ bool id_h(connection_t *c)
return false; return false;
} }
/* If we set c->name in advance, make sure we are connected to the right host */ /* If this is an outgoing connection, make sure we are connected to the right host */
if(c->name) { if(c->outgoing) {
if(strcmp(c->name, name)) { if(strcmp(c->name, name)) {
logger(LOG_ERR, _("Peer %s is %s instead of %s"), c->hostname, name, logger(LOG_ERR, _("Peer %s is %s instead of %s"), c->hostname, name,
c->name); c->name);