mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
tlv: don't crash when you fail to parse the TLV
passing back a null TLV was crashing here, because we tried to dereference a null pointer. instead, we put it into a temporary struct that we can check for NULL-ness, before assigning to the passed in pointer.
This commit is contained in:
parent
d8738452ed
commit
28c3f9ca21
1 changed files with 3 additions and 2 deletions
|
@ -504,10 +504,11 @@ class Message(object):
|
|||
elif f.is_tlv:
|
||||
if not f.is_variable_size():
|
||||
raise TypeError('TLV {} not variable size'.format(f.name))
|
||||
subcalls.append('{tlv_name} = fromwire__{tlv_name}(ctx, &cursor, &plen, &{tlv_len});'
|
||||
subcalls.append('struct {tlv_name} *_tlv = fromwire__{tlv_name}(ctx, &cursor, &plen, &{tlv_len});'
|
||||
.format(tlv_name=f.name, tlv_len=f.lenvar))
|
||||
subcalls.append('if (!{tlv_name})'.format(tlv_name=f.name))
|
||||
subcalls.append('if (!_tlv)')
|
||||
subcalls.append('return false;')
|
||||
subcalls.append('*{tlv_name} = *_tlv;'.format(tlv_name=f.name))
|
||||
elif f.is_variable_size():
|
||||
subcalls.append("//2nd case {name}".format(name=f.name))
|
||||
typename = f.fieldtype.name
|
||||
|
|
Loading…
Add table
Reference in a new issue