Browse Source

gossipd: fix calculation of crc32 of update.

Currently EXPERIMENTAL_FEATURES only, fortunately.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pull/2938/head
Rusty Russell 5 years ago
committed by Christian Decker
parent
commit
d1a1592cc8
  1. 9
      gossipd/gossipd.c

9
gossipd/gossipd.c

@ -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;
}

Loading…
Cancel
Save