Skip to content

Ensure that packet is set to p param to type of bytes. In certain sit… #3909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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.
@@ -633,7 +660,7 @@ class _BGPCapability_metaclass(_BGPCap_metaclass, Packet_metaclass):
pass


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?

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.

@@ -449,7 +476,7 @@ class BGPHeader(Packet):
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

@@ -117,25 +119,50 @@ def i2m(self, pkt, i):
""""Internal" (IP as bytes, mask as int) to "machine"
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.

"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

"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

subpacklen = lambda p: len(p)
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