2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +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:
Jarrod Johnson 2021-12-20 12:28:35 -05:00
parent a8132d87a7
commit abec8c498c
2 changed files with 6 additions and 4 deletions

View File

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

View File

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