From 1f320af8e59a5ffe935dad6fdab7ab7036c8db8c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 18 May 2021 09:44:02 -0400 Subject: [PATCH] Add error message for long profile names If a profile name pushes the filename field of dhcp beyond what it can support, log an event and do not offer a corrupted dhcp offer packet. --- .../confluent/discovery/protocols/pxe.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/confluent_server/confluent/discovery/protocols/pxe.py b/confluent_server/confluent/discovery/protocols/pxe.py index 625ab99b..e0d1719f 100644 --- a/confluent_server/confluent/discovery/protocols/pxe.py +++ b/confluent_server/confluent/discovery/protocols/pxe.py @@ -276,6 +276,13 @@ def proxydhcp(): bootfile = b'confluent/x86_64/ipxe.efi' elif disco['arch'] == 'bios-x86': bootfile = b'confluent/x86_64/ipxe.kkpxe' + if len(bootfile) > 127: + log.log( + {'info': 'Boot offer cannot be made to {0} as the ' + 'profile name "{1}" is {2} characters longer than is supported ' + 'for this boot method.'.format( + node, profile, len(bootfile) - 127)}) + continue rpv[:240] = rqv[:240].tobytes() rpv[0:1] = b'\x02' rpv[108:108 + len(bootfile)] = bootfile @@ -485,6 +492,13 @@ def check_reply(node, info, packet, sock, cfg, reqview): ) if not isinstance(bootfile, bytes): bootfile = bootfile.encode('utf8') + if len(bootfile) > 127: + log.log( + {'info': 'Boot offer cannot be made to {0} as the ' + 'profile name "{1}" is {2} characters longer than is supported ' + 'for this boot method.'.format( + node, profile, len(bootfile) - 127)}) + return repview[108:108 + len(bootfile)] = bootfile repview[20:24] = myipn gateway = None