Fixed error handling in resume data processing.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 17 Feb 2004 22:27:47 +0000 (22:27 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 17 Feb 2004 22:27:47 +0000 (22:27 +0000)
CHANGES
lib/silcclient/client.c
lib/silcclient/client_resume.c
lib/silcclient/protocol.h

diff --git a/CHANGES b/CHANGES
index a9451e2bdbc73915428dedb772ca5eada8f398ea..5a820180833372172fae7e3daf8376cd1dbea20f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Wed Feb 18 02:46:17 EET 2004  Pekka Riikonen <priikone@silcnet.org>
+
+       * Fixed error handling in resuming data processing.  Affected
+         files are lib/silcclient/client_resume.c and client.c.
+
 Tue Feb 17 19:34:30 EET 2004  Pekka Riikonen <priikone@silcnet.org>
 
        * Fixed silc_client_send_private_message to return TRUE correctly.
index ef15e5463fa6ba16ae1fe9f30ced4da14e36352f..27df40626bc8ef2153264559499b7dcf32293942 100644 (file)
@@ -587,8 +587,7 @@ SILC_TASK_CALLBACK(silc_client_connect_failure_auth)
     (SilcClientConnAuthInternalContext *)context;
   SilcClient client = (SilcClient)ctx->client;
 
-  client->internal->ops->connected(client, ctx->sock->user_data,
-                                  SILC_CLIENT_CONN_ERROR_AUTH);
+  client->internal->ops->connected(client, ctx->sock->user_data, ctx->status);
   silc_free(ctx);
 }
 
@@ -789,6 +788,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
       protocol->state == SILC_PROTOCOL_STATE_FAILURE) {
     /* Error occured during protocol */
     SILC_LOG_DEBUG(("Error during authentication protocol"));
+    ctx->status = SILC_CLIENT_CONN_ERROR_AUTH;
     goto err;
   }
 
@@ -800,12 +800,15 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
     unsigned char *old_id;
     SilcUInt16 old_id_len;
 
-    if (!silc_client_process_detach_data(client, conn, &old_id, &old_id_len))
+    if (!silc_client_process_detach_data(client, conn, &old_id, &old_id_len)) {
+      ctx->status = SILC_CLIENT_CONN_ERROR_RESUME;
       goto err;
+    }
 
     old_client_id = silc_id_str2id(old_id, old_id_len, SILC_ID_CLIENT);
     if (!old_client_id) {
       silc_free(old_id);
+      ctx->status = SILC_CLIENT_CONN_ERROR_RESUME;
       goto err;
     }
 
@@ -818,6 +821,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
     if (!auth) {
       silc_free(old_client_id);
       silc_free(old_id);
+      ctx->status = SILC_CLIENT_CONN_ERROR_RESUME;
       goto err;
     }
 
index 54df971f27d73ed1e8f9abb37f880f36b6429c84..928c7df9f4024102800538e064c8841e1ae2c97b 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2002, 2003 Pekka Riikonen
+  Copyright (C) 2002, 2004 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
@@ -110,18 +110,21 @@ bool silc_client_process_detach_data(SilcClient client,
   SilcBufferStruct detach;
   SilcUInt32 ch_count;
   int i, len;
+  char *newnick;
 
   SILC_LOG_DEBUG(("Start"));
 
-  silc_free(conn->nickname);
   silc_buffer_set(&detach, conn->internal->params.detach_data,
                  conn->internal->params.detach_data_len);
 
   SILC_LOG_HEXDUMP(("Detach data"), detach.data, detach.len);
 
+  *old_id = NULL;
+  *old_id_len = 0;
+
   /* Take the old client ID from the detachment data */
   len = silc_buffer_unformat(&detach,
-                            SILC_STR_UI16_NSTRING_ALLOC(&conn->nickname,
+                            SILC_STR_UI16_NSTRING_ALLOC(&newnick,
                                                         NULL),
                             SILC_STR_UI16_NSTRING_ALLOC(old_id, old_id_len),
                             SILC_STR_UI_INT(NULL),
@@ -129,6 +132,11 @@ bool silc_client_process_detach_data(SilcClient client,
                             SILC_STR_END);
   if (len == -1)
     return FALSE;
+  if (!newnick || !(*old_id) || !(*old_id_len))
+    return FALSE;
+
+  silc_free(conn->nickname);
+  conn->nickname = newnick;
 
   silc_buffer_pull(&detach, len);
 
index 9d93709210bd550ea29801218564d2c1b3ec225e..019fa37adbc5af7364bacec5e30b73021c389b2a 100644 (file)
@@ -2,15 +2,14 @@
 
   protocol.h
 
-  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+  Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2000 Pekka Riikonen
+  Copyright (C) 1997 - 2004 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
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-  
+  the Free Software Foundation; version 2 of the License.
+
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -52,6 +51,7 @@ typedef struct {
 typedef struct {
   void *client;
   SilcSocketConnection sock;
+  SilcClientConnectionStatus status;
 
   /* SKE object from Key Exchange protocol. */
   SilcSKE ske;