From 29befa9059ca8b9d2f0f1b415c6b99b34cdcb6fd Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Mon, 20 Nov 2006 14:54:26 +0000 Subject: [PATCH] Don't return request socket info if they don't exist, return FALSE. --- lib/silcutil/silcsocketstream.c | 20 +++++++++++++++++--- lib/silcutil/silcsocketstream.h | 14 ++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/silcutil/silcsocketstream.c b/lib/silcutil/silcsocketstream.c index b599dabf..86e915b7 100644 --- a/lib/silcutil/silcsocketstream.c +++ b/lib/silcutil/silcsocketstream.c @@ -263,12 +263,21 @@ SilcBool silc_socket_stream_get_info(SilcStream stream, if (sock) *sock = socket_stream->sock; - if (hostname) + if (hostname) { + if (!socket_stream->hostname) + return FALSE; *hostname = socket_stream->hostname; - if (ip) + } + if (ip) { + if (!socket_stream->ip) + return FALSE; *ip = socket_stream->ip; - if (port) + } + if (port) { + if (!socket_stream->port) + return FALSE; *port = socket_stream->port; + } return TRUE; } @@ -295,6 +304,11 @@ SilcBool silc_socket_stream_set_info(SilcStream stream, socket_stream->ip = strdup(ip); if (!socket_stream->ip) return FALSE; + if (!socket_stream->hostname) { + socket_stream->hostname = strdup(ip); + if (!socket_stream->hostname) + return FALSE; + } } if (port) socket_stream->port = port; diff --git a/lib/silcutil/silcsocketstream.h b/lib/silcutil/silcsocketstream.h index 17e64b5a..f135ca54 100644 --- a/lib/silcutil/silcsocketstream.h +++ b/lib/silcutil/silcsocketstream.h @@ -108,7 +108,8 @@ typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status, * have valid hostname and IP address, otherwise the stream creation will * fail. If it is FALSE then only valid IP address is required. Note that, * if the `lookup' is FALSE then the hostname, IP and port information - * will not be available from the socket stream. + * will not be available from the socket stream. In that case this will + * also return NULL as the `callback' is called immediately. * ***/ SilcAsyncOperation @@ -180,11 +181,12 @@ SilcBool silc_socket_stream_get_info(SilcStream stream, * * Use this function to set the hostname, IP address and remote port * information to the socket stream indicated by `stream' if you did not - * perform lookup in the silc_socket_create_stream. This is not mandatory - * but if you would like to associate the information with the stream - * use this function. If the lookup was performed when creating the - * stream then calling this function is not necessary. Use the function - * silc_socket_stream_get_info to get the information from the stream. + * perform lookup in the silc_socket_tcp_stream_create. This is not + * mandatory but if you would like to associate the information with the + * stream use this function. If the lookup was performed when creating + * the stream then calling this function is not necessary. Use the + * function silc_socket_stream_get_info to get the information from the + * stream. * ***/ SilcBool silc_socket_stream_set_info(SilcStream stream, -- 2.43.0