silcclient: handle command timeout error correctly
authorPekka Riikonen <priikone@silcnet.org>
Tue, 6 May 2014 15:24:58 +0000 (18:24 +0300)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 6 May 2014 15:24:58 +0000 (18:24 +0300)
If command which can return a list of entries such as the LIST command
timeouts the cmd->status may be something other than SILC_STATUS_OK,
ie. _LIST_END for example which then means ERROR_CALLBACK won't update
the SILC_STATUS_ERR_TIMEOUT correctly to the cmd context.  This can
crash the application handling the command reply.  Clear the cmd->status
in case the command timedout.

lib/silcclient/command_reply.c

index 57c339aaf334adbb5e1a3d3699a000d6039cf46a..a3838f4e5b04b869f8eb1c958ebdec50a4050b63 100644 (file)
@@ -246,6 +246,7 @@ SILC_FSM_STATE(silc_client_command_reply_timeout)
 
   /* Timeout, reply not received in timely fashion */
   silc_list_del(conn->internal->pending_commands, cmd);
+  cmd->status = SILC_STATUS_OK;
   ERROR_CALLBACK(SILC_STATUS_ERR_TIMEDOUT);
   return SILC_FSM_FINISH;
 }