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

Fix #16. Padding byte was not properly discarded.

This commit is contained in:
Emmanuel Blot 2020-04-17 16:04:02 +02:00
parent 7069761bcf
commit a9c03c94bf
3 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2010-2019 Emmanuel Blot <emmanuel.blot@free.fr> # Copyright (c) 2010-2020 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2010-2011 Neotion # Copyright (c) 2010-2011 Neotion
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
import os import os
__version__ = '1.7.1' __version__ = '1.7.2'
def pybootd_path(path): def pybootd_path(path):

View File

@ -294,7 +294,8 @@ class BootpServer:
# padding # padding
if tag == 0: if tag == 0:
padding_count += 1 padding_count += 1
if padding_count > 255: tail = tail[1:]
if padding_count > 0xFF:
raise ValueError('Padding overflow') raise ValueError('Padding overflow')
continue continue
padding_count = 0 padding_count = 0

View File

@ -27,10 +27,10 @@ from binascii import hexlify, unhexlify
from io import StringIO from io import StringIO
from socket import (socket, timeout, AF_INET, SOCK_DGRAM, IPPROTO_UDP, from socket import (socket, timeout, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
SOL_SOCKET, SO_BROADCAST, SO_REUSEADDR) SOL_SOCKET, SO_BROADCAST, SO_REUSEADDR)
from sys import modules, stdout from sys import modules
from textwrap import fill from textwrap import fill
from time import sleep from time import sleep
from unittest import TestCase, TestSuite, SkipTest, makeSuite, main as ut_main from unittest import TestCase, TestSuite, makeSuite, main as ut_main
from pybootd.daemons import BootpDaemon from pybootd.daemons import BootpDaemon
from pybootd.util import EasyConfigParser, logger_factory from pybootd.util import EasyConfigParser, logger_factory
@ -122,12 +122,12 @@ default = pxelinux.0
self.sock.sendto(req, ('<broadcast>', 67)) self.sock.sendto(req, ('<broadcast>', 67))
try: try:
resp = self.sock.recv(1024) resp = self.sock.recv(1024)
print('response:\n', # print('response:\n',
fill(hexlify(resp).decode(), # fill(hexlify(resp).decode(),
initial_indent=' ', # initial_indent=' ',
subsequent_indent=' ')) # subsequent_indent=' '))
except timeout: except timeout:
print('Timeout') self.assertFalse(True, 'No response from response')
def suite(): def suite():
suite_ = TestSuite() suite_ = TestSuite()