From 662217f4097b2efbde5f7f9a190ad1b031f35716 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 15 Aug 2014 10:25:38 +0200 Subject: [PATCH] packet: Check return value of ssh_buffer_unpack(). CID: 1230357 Signed-off-by: Andreas Schneider Reviewed-by: Aris Adamantiadis --- src/packet.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/packet.c b/src/packet.c index 3ed286df..d16cd165 100644 --- a/src/packet.c +++ b/src/packet.c @@ -461,14 +461,23 @@ int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum){ * @brief handles a SSH_MSG_UNIMPLEMENTED packet */ SSH_PACKET_CALLBACK(ssh_packet_unimplemented){ - uint32_t seq; + uint32_t seq; + int rc; + (void)session; /* unused */ - (void)type; - (void)user; - ssh_buffer_unpack(packet, "d", &seq); - SSH_LOG(SSH_LOG_RARE, - "Received SSH_MSG_UNIMPLEMENTED (sequence number %d)",seq); - return SSH_PACKET_USED; + (void)type; + (void)user; + + rc = ssh_buffer_unpack(packet, "d", &seq); + if (rc != SSH_OK) { + SSH_LOG(SSH_LOG_WARNING, + "Could not unpack SSH_MSG_UNIMPLEMENTED packet"); + } + + SSH_LOG(SSH_LOG_RARE, + "Received SSH_MSG_UNIMPLEMENTED (sequence number %d)",seq); + + return SSH_PACKET_USED; } /** @internal