Fix file transfer crash
[silc.git] / apps / irssi / src / silc / core / client_ops.c
index 16feddc7583a8b2c18dd200f736473b2a8ba6d92..75f3b147728d15937001fcac93bf36d6e0b595bd 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  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
@@ -262,10 +262,11 @@ int verify_message_signature(SilcClientEntry sender,
                                      sizeof(sender->fingerprint));
       if (strcmp(fingerprint, fingerprint2)) {
         /* since the public key differs from the senders public key, the
-           verification _failed_ */
+           verification won't be done */
         silc_pkcs_public_key_free(pk);
         silc_free(fingerprint);
-        ret = SILC_MSG_SIGNED_UNKNOWN;
+        silc_free(fingerprint2);
+       return SILC_MSG_SIGNED_UNKNOWN;
       }
       silc_free(fingerprint2);
     }
@@ -945,7 +946,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
        tmp = cp;
       }
 
-      chanrec->topic = *tmp == '\0' ? NULL : g_strdup(tmp);
+      chanrec->topic = (tmp && *tmp == '\0' ? NULL : g_strdup(tmp));
       signal_emit("channel topic changed", 1, chanrec);
 
       silc_free(dm);
@@ -1677,7 +1678,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
 
       if (idle && nickname) {
        memset(buf, 0, sizeof(buf));
-       snprintf(buf, sizeof(buf) - 1, "%lu %s",
+       snprintf(buf, sizeof(buf) - 1, "%u %s",
                 idle > 60 ? (idle / 60) : idle,
                 idle > 60 ? "minutes" : "seconds");
 
@@ -2401,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)
@@ -2474,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) {