Skip to content

[minor] Using in { } rather than in [ ] in dot11.py #5070

Description

@nrathaus

Brief description

In the latest HEAD (git) dot11.py has:
lambda pkt: (pkt.type not in {1, 3} or

While this works, it doesn't correctly function when you call fuzz(..) on dot11, while having it written like this:
lambda pkt: (pkt.type not in [1, 3] or

Doesn't manifest this issue (calling fuzz(..) failing)

Same bug exists also in this line:
ConditionalField(LEShortField("SC", 0), lambda pkt: pkt.type not in {1, 3}),

I can provide a PR - but this is a minor bug / patch that I think a full PR is a bit too much :)

Scapy version

5e13d41

Python version

3.11

Operating system

Linux

Additional environment information

No response

How to reproduce

UTS style reproduction is ok?

= Dot11 - ConditionalField conditions must not require hashing a volatile value
~ dot11

# Regression test.
#
# Dot11's 'addr2' and 'SC' fields are ConditionalFields whose condition
# tests set membership: `lambda pkt: pkt.type not in {1, 3}`. Scapy supports
# assigning a RandNum-family volatile object directly as a field's value -
# the same documented idiom as IP(ttl=RandByte()) or IP(id=RandShort()) -
# and VolatileValue.__hash__ is intentionally disabled (VolatileValue
# instances are unhashable). A set membership test needs to hash its
# operand, so as soon as 'type' is such a live volatile value, evaluating
# the condition raises TypeError, even though the exact same check written
# with a list instead of a set works fine (list membership uses __eq__,
# which VolatileValue does implement).
#
# This never surfaces through fuzz(Dot11()) alone, because Dot11 also
# defines a MultipleTypeField (FCfield): fuzz() freezes every other
# volatile value into a concrete one as soon as a packet has any
# MultipleTypeField, which incidentally hides this bug. Assigning the
# volatile value directly, as below, bypasses that and reproduces it
# directly against upstream Scapy.

pkt = Dot11(type=RandNum(0, 3))
assert expect_exception(TypeError, lambda: pkt.show(dump=True))

Actual result

No response

Expected result

No response

Related resources

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions