Skip to content

Conversation

@muttiopenbts
Copy link

Checklist:

  • If you are new to Scapy: I have checked CONTRIBUTING.md (esp. section submitting-pull-requests)
  • I squashed commits belonging together
  • I executed the regression tests (using cd test && ./run_tests or tox)

Ensure that params that representing packets are set to type bytes. In certain situations where bgp fields for open messages were being set, this function was initializing packet variable to a str and returning.

Fix bgp path_attrib length field. Should be type byte, not int.

Adding fuzz() support to bgp open and update.

Allow for BGPFieldLenField len to be fuzzed, but fixed when recalled.

…uations where bgp fields for open messages where being set, this function was initializing packet variable to a str and returning.

Fix bgp path_attrib length field. Should be type byte, not int.

Adding fuzz() support to bgp open and update.

Allow for BGPFieldLenField len to be fuzzed, but fixed when recalled.


class BGPCapability(Packet, metaclass=_BGPCapability_metaclass):
class BGPCapability(six.with_metaclass(_BGPCapability_metaclass, Packet)): # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just dropped Python 2 support so you shouldn't need to use six

return enum.get(i, i)
if self.enum_from:
enum = self.enum_from(pkt)
return enum.get(i, i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else?

def post_build(self, p, pay):
# type: (bytes, bytes) -> bytes
subpacklen = lambda p: len(p)
packet = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0xffffffffffffffffffffffffffffffff,
0x80
),
ShortField("len", None),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very not scapy-like. Don't do that. It is commonly understood that len=None -> auto-computed.
You can always set this to 0 before calling fuzz

:param int min: Minimum range for random value.
:param int max: Maximum range for random value.
"""
RandNum.__init__(self, min, max)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use super

representation."""
mask, ip = i
ip = socket.inet_aton(ip)
ip = socket.inet_aton(str(ip))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? (add a comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inet_aton expects a string representation of an ip address.
I'm ensuring that is the case, and any errors will make this obvious.

BGPFieldLenField(
"withdrawn_routes_len",
None,
0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. Leave None here

BGPFieldLenField(
"path_attr_len",
None,
0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

packet = ""
packet = p

if self.withdrawn_routes_len is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave None here...

...otherwise this won't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants