mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
features: fix features_supported() function.
1. We need to test all bits, not all bytes. 2. Both local and global features need to be supported. 3. Untested code is broken code. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
149e967ba3
commit
4359f46ffd
@@ -98,7 +98,7 @@ static bool all_supported_features(const u8 *bitmap,
|
||||
const u32 *supported,
|
||||
size_t num_supported)
|
||||
{
|
||||
size_t len = tal_count(bitmap);
|
||||
size_t len = tal_count(bitmap) * 8;
|
||||
|
||||
/* It's OK to be odd: only check even bits. */
|
||||
for (size_t bitnum = 0; bitnum < len; bitnum += 2) {
|
||||
@@ -124,7 +124,7 @@ bool features_supported(const u8 *gfeatures, const u8 *lfeatures)
|
||||
return all_supported_features(gfeatures,
|
||||
global_features,
|
||||
ARRAY_SIZE(global_features))
|
||||
|| all_supported_features(lfeatures,
|
||||
&& all_supported_features(lfeatures,
|
||||
local_features,
|
||||
ARRAY_SIZE(local_features));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user