Skip to content

Commit

Permalink
gossipd: fix calculation of crc32 of update.
Browse files Browse the repository at this point in the history
Currently EXPERIMENTAL_FEATURES only, fortunately.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 27, 2019
1 parent 9dd3142 commit 0a40e0f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0a40e0f

Please sign in to comment.