layers/ipsec: fix padding problems with fuzzed packets

When generating packets with fuzz(), some fields are not initialized
completely. This causes problems in evaluating the amount of padding
necessary to align the encrypted data length to a multiple of the crypto
algorithm block size.

This patch forces the encrypted packet fields to be resolved to their
default values before calculating the pad length.

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
This commit is contained in:
Robin Jarry 2014-09-16 17:13:56 +02:00
parent 9201f1cf13
commit 876f5a3361
1 changed files with 2 additions and 4 deletions

View File

@ -606,9 +606,6 @@ if AES and XCBCMAC:
icv_size=12, icv_size=12,
key_size=(16,)) key_size=(16,))
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def split_for_transport(orig_pkt, transport_proto): def split_for_transport(orig_pkt, transport_proto):
""" """
@ -621,7 +618,8 @@ def split_for_transport(orig_pkt, transport_proto):
@return: a tuple (header, nh, payload) where nh is the protocol number of @return: a tuple (header, nh, payload) where nh is the protocol number of
payload. payload.
""" """
header = orig_pkt.copy() # force resolution of default fields to avoid padding errors
header = orig_pkt.__class__(str(orig_pkt))
next_hdr = header.payload next_hdr = header.payload
nh = None nh = None