gossipd: fix calculation of crc32 of update.

Currently EXPERIMENTAL_FEATURES only, fortunately.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-08-27 13:35:38 +09:30 committed by Christian Decker
parent 5b5d70d640
commit d1a1592cc8
1 changed files with 5 additions and 4 deletions

View File

@ -988,11 +988,12 @@ static u32 crc32_of_update(const u8 *channel_update)
* * [`u32`:`timestamp`]
*...
*/
/* Note: 2 bytes for `type` field */
/* We already checked it's valid before accepting */
assert(tal_count(channel_update) > 64 + 32 + 8 + 4);
sum = crc32c(0, channel_update + 64, 32 + 8);
sum = crc32c(sum, channel_update + 64 + 32 + 8 + 4,
tal_count(channel_update) - (64 + 32 + 8 + 4));
assert(tal_count(channel_update) > 2 + 64 + 32 + 8 + 4);
sum = crc32c(0, channel_update + 2 + 64, 32 + 8);
sum = crc32c(sum, channel_update + 2 + 64 + 32 + 8 + 4,
tal_count(channel_update) - (64 + 2 + 32 + 8 + 4));
return sum;
}