From 480dd127c8a539036ff82a3810a0ad83136944f8 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 16 May 2007 14:42:08 +0000 Subject: [PATCH] Make sure connection->name is never NULL. --- src/connection.c | 5 ++++- src/net_socket.c | 4 ++-- src/protocol_auth.c | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/connection.c b/src/connection.c index c4c9fd48..53c0fd04 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,6 +1,6 @@ /* connection.c -- connection list management - Copyright (C) 2000-2006 Guus Sliepen , + Copyright (C) 2000-2007 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -78,6 +78,9 @@ void free_connection(connection_t *c) { cp(); + if(c->name) + free(c->name); + if(c->hostname) free(c->hostname); diff --git a/src/net_socket.c b/src/net_socket.c index 149b0d3b..bf5130d6 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -1,7 +1,7 @@ /* net_socket.c -- Handle various kinds of sockets. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2006 Guus Sliepen + 2000-2007 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 @@ -424,7 +424,7 @@ bool handle_new_meta_connection(int sock) sockaddrunmap(&sa); c = new_connection(); - c->name = NULL; + c->name = xstrdup(""); c->outcipher = myself->connection->outcipher; c->outdigest = myself->connection->outdigest; c->outmaclength = myself->connection->outmaclength; diff --git a/src/protocol_auth.c b/src/protocol_auth.c index f8a15be8..0efeceb2 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-2006 Guus Sliepen + 2000-2007 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,9 +68,9 @@ bool id_h(connection_t *c) 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)) { logger(LOG_ERR, _("Peer %s is %s instead of %s"), c->hostname, name, c->name); -- 2.20.1