mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 09:32:21 +00:00
Break netlink address fetch on invalid rta_len
It is considered valid for kernel to return a null rta_len in the midst of data and expect the caller to terminate.
This commit is contained in:
parent
a8132d87a7
commit
abec8c498c
@ -55,10 +55,10 @@ def get_my_addresses():
|
||||
rta = v[nlhdrsz+ifaddrsz:length]
|
||||
while len(rta):
|
||||
rtalen, rtatyp = struct.unpack('HH', rta[:4])
|
||||
if rtalen < 4:
|
||||
break
|
||||
if rtatyp == 1:
|
||||
addrs.append((fam, rta[4:rtalen], plen, ridx))
|
||||
if not rtalen:
|
||||
break
|
||||
rta = rta[rtalen:]
|
||||
v = v[length:]
|
||||
return addrs
|
||||
|
@ -563,6 +563,8 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
|
||||
rta = v[nlhdrsz+ifaddrsz:length]
|
||||
while len(rta):
|
||||
rtalen, rtatyp = struct.unpack('HH', rta[:4])
|
||||
if rtalen < 4:
|
||||
break
|
||||
if rta[4:rtalen].tobytes() == matchlla:
|
||||
return get_my_addresses(idx=ridx)
|
||||
rta = rta[rtalen:]
|
||||
@ -570,10 +572,10 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
|
||||
rta = v[nlhdrsz+ifaddrsz:length]
|
||||
while len(rta):
|
||||
rtalen, rtatyp = struct.unpack('HH', rta[:4])
|
||||
if rtalen < 4:
|
||||
break
|
||||
if rtatyp == 1:
|
||||
addrs.append((fam, rta[4:rtalen].tobytes(), plen, ridx))
|
||||
if not rtalen:
|
||||
break
|
||||
rta = rta[rtalen:]
|
||||
v = v[length:]
|
||||
return addrs
|
||||
|
Loading…
Reference in New Issue
Block a user