1
1
mirror of https://github.com/eblot/pybootd.git synced 2024-09-11 22:17:44 +03:00

Should address #13: infinite padding decoding loop

This commit is contained in:
Emmanuel Blot 2019-09-06 18:45:12 +02:00
parent 9992ae524b
commit 3c9603ab5d

View File

@ -287,11 +287,16 @@ class BootpServer:
def parse_options(self, tail): def parse_options(self, tail):
self.log.debug('Parsing DHCP options') self.log.debug('Parsing DHCP options')
dhcp_tags = {} dhcp_tags = {}
padding_count = 0
while tail: while tail:
tag = tail[0] tag = tail[0]
# padding # padding
if tag == 0: if tag == 0:
padding_count += 1
if padding_count > 255:
raise ValueError('Padding overflow')
continue continue
padding_count = 0
if tag == 0xff: if tag == 0xff:
return dhcp_tags return dhcp_tags
length = tail[1] length = tail[1]