X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilccommand.c;h=1c16ac6c61ea915ef91988b84e9f55c7926e6aa3;hb=48d89bc2868ec49c2ab9aa74efe9ac703eee8f29;hp=187054199d4ded4c644b794087f7be2156965f8d;hpb=10ec50cff8ad9d6a77080821037c1234dc066b47;p=silc.git diff --git a/lib/silccore/silccommand.c b/lib/silccore/silccommand.c index 18705419..1c16ac6c 100644 --- a/lib/silccore/silccommand.c +++ b/lib/silccore/silccommand.c @@ -46,18 +46,23 @@ SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer) SilcCommandPayload new; unsigned char args_num; unsigned short payload_len; + int ret; SILC_LOG_DEBUG(("Parsing command payload")); new = silc_calloc(1, sizeof(*new)); /* Parse the Command Payload */ - silc_buffer_unformat(buffer, - SILC_STR_UI_SHORT(&payload_len), - SILC_STR_UI_CHAR(&new->cmd), - SILC_STR_UI_CHAR(&args_num), - SILC_STR_UI_SHORT(&new->ident), - SILC_STR_END); + ret = silc_buffer_unformat(buffer, + SILC_STR_UI_SHORT(&payload_len), + SILC_STR_UI_CHAR(&new->cmd), + SILC_STR_UI_CHAR(&args_num), + SILC_STR_UI_SHORT(&new->ident), + SILC_STR_END); + if (ret == -1) { + silc_free(new); + return NULL; + } if (payload_len != buffer->len) { SILC_LOG_ERROR(("Incorrect command payload in packet, packet dropped"));