From d0c0355c2fa9ef0aa699010242479366c06b7041 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Mon, 28 Apr 2014 15:05:58 +0300 Subject: [PATCH] Fix file transfer crash When silc-client accepts new file transfer and receives public key to verify it will crash because the client connection has no Irssi server associated to it. Handle this gracefully. Call the sucessful public key verify completion after the key has been saved because the completion callback may free the public key. --- apps/irssi/src/silc/core/client_ops.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index d73c7bee..75f3b147 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2001 - 2008 Pekka Riikonen + Copyright (C) 2001 - 2014 Pekka Riikonen 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 @@ -2402,13 +2402,13 @@ static void verify_public_key_completion(const char *line, void *context, SilcBool success = (reason == KeyboardCompletionSuccess); if (success && (line[0] == 'Y' || line[0] == 'y')) { - /* Call the completion */ - if (verify->completion) - verify->completion(TRUE, verify->context); - /* Save the key for future checking */ silc_pkcs_save_public_key(verify->filename, verify->public_key, SILC_PKCS_FILE_BASE64); + + /* Call the completion */ + if (verify->completion) + verify->completion(TRUE, verify->context); } else { /* Call the completion */ if (verify->completion) @@ -2475,12 +2475,14 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn, "server" : "client"); int i; - server = (SILC_SERVER_REC*)conn->context; - SILC_VERIFY(server); - if (!server) { - if (completion) - completion(FALSE, context); - return; + if (conn_type != SILC_CONN_CLIENT) { + server = (SILC_SERVER_REC*)conn->context; + SILC_VERIFY(server); + if (!server) { + if (completion) + completion(FALSE, context); + return; + } } if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) { -- 2.24.0