From 7a12ea32789c652cdbe6fc98b5b93724d6599635 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 19 Feb 2015 13:54:07 +0100 Subject: [SERVER] Fix really stupid bug where received data gets written to random memory --- src/server/protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/protocol.h b/src/server/protocol.h index ad286d1..41c6410 100644 --- a/src/server/protocol.h +++ b/src/server/protocol.h @@ -24,7 +24,7 @@ static inline int dnbd3_read_reply(int sock, dnbd3_reply_t *reply, bool wait) if ( errno == EINTR ) return REPLY_INTR; return REPLY_ERRNO; } - if ( !wait && ret != sizeof(*reply) ) ret += recv( sock, reply + ret, sizeof(*reply) - ret, MSG_WAITALL | MSG_NOSIGNAL ); + if ( !wait && ret != sizeof(*reply) ) ret += recv( sock, ((char*)reply) + ret, sizeof(*reply) - ret, MSG_WAITALL | MSG_NOSIGNAL ); if ( ret != sizeof(*reply) ) return REPLY_INCOMPLETE; fixup_reply( *reply ); if ( reply->magic != dnbd3_packet_magic ) return REPLY_WRONGMAGIC; -- cgit v1.2.3-55-g7522