From 88b89987595c705ee2087cad37c64bf134974960 Mon Sep 17 00:00:00 2001 From: Shargon Date: Thu, 19 Dec 2019 10:35:07 +0100 Subject: [PATCH 1/4] Set limits in MerkleBlockPayload (3x) --- src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs index cf2dcba2d9..2cd345628b 100644 --- a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs +++ b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs @@ -37,9 +37,9 @@ public static MerkleBlockPayload Create(Block block, BitArray flags) public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); - ContentCount = (int)reader.ReadVarInt(int.MaxValue); - Hashes = reader.ReadSerializableArray(); - Flags = reader.ReadVarBytes(); + ContentCount = (int)reader.ReadVarInt(Block.MaxTransactionsPerBlock); + Hashes = reader.ReadSerializableArray(Block.MaxTransactionsPerBlock); + Flags = reader.ReadVarBytes(Block.MaxTransactionsPerBlock); } public override void Serialize(BinaryWriter writer) From c02af40de8204ff0f5eca30080a2b81e40304998 Mon Sep 17 00:00:00 2001 From: Shargon Date: Sat, 21 Dec 2019 11:19:28 +0100 Subject: [PATCH 2/4] Update MerkleBlockPayload.cs --- src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs index 2cd345628b..3154447601 100644 --- a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs +++ b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs @@ -39,7 +39,7 @@ public override void Deserialize(BinaryReader reader) base.Deserialize(reader); ContentCount = (int)reader.ReadVarInt(Block.MaxTransactionsPerBlock); Hashes = reader.ReadSerializableArray(Block.MaxTransactionsPerBlock); - Flags = reader.ReadVarBytes(Block.MaxTransactionsPerBlock); + Flags = reader.ReadVarBytes(Block.MaxTransactionsPerBlock / 8); } public override void Serialize(BinaryWriter writer) From fcbf8f879824ebb0346d8c69cc784ae0f3e64daf Mon Sep 17 00:00:00 2001 From: Shargon Date: Sat, 21 Dec 2019 11:58:12 +0100 Subject: [PATCH 3/4] Update src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs Co-Authored-By: Erik Zhang --- src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs index 3154447601..a6e51b45ac 100644 --- a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs +++ b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs @@ -39,7 +39,7 @@ public override void Deserialize(BinaryReader reader) base.Deserialize(reader); ContentCount = (int)reader.ReadVarInt(Block.MaxTransactionsPerBlock); Hashes = reader.ReadSerializableArray(Block.MaxTransactionsPerBlock); - Flags = reader.ReadVarBytes(Block.MaxTransactionsPerBlock / 8); + Flags = reader.ReadVarBytes((Block.MaxTransactionsPerBlock + 7) / 8); } public override void Serialize(BinaryWriter writer) From 0a724f01b70e093006c66e5e0bd96ea07f3a5ed4 Mon Sep 17 00:00:00 2001 From: Shargon Date: Sun, 22 Dec 2019 10:35:30 +0100 Subject: [PATCH 4/4] Update MerkleBlockPayload.cs --- src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs index a6e51b45ac..8a735587cd 100644 --- a/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs +++ b/src/neo/Network/P2P/Payloads/MerkleBlockPayload.cs @@ -37,9 +37,9 @@ public static MerkleBlockPayload Create(Block block, BitArray flags) public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); - ContentCount = (int)reader.ReadVarInt(Block.MaxTransactionsPerBlock); - Hashes = reader.ReadSerializableArray(Block.MaxTransactionsPerBlock); - Flags = reader.ReadVarBytes((Block.MaxTransactionsPerBlock + 7) / 8); + ContentCount = (int)reader.ReadVarInt(Block.MaxTransactionsPerBlock + 1); + Hashes = reader.ReadSerializableArray(ContentCount); + Flags = reader.ReadVarBytes((ContentCount + 7) / 8); } public override void Serialize(BinaryWriter writer)