Skip to content

Fix MultipleTypeField initialization#1550

Merged
p-l- merged 1 commit intosecdev:masterfrom
gpotter2:multit-fix
Aug 15, 2018
Merged

Fix MultipleTypeField initialization#1550
p-l- merged 1 commit intosecdev:masterfrom
gpotter2:multit-fix

Conversation

@gpotter2
Copy link
Copy Markdown
Member

@gpotter2 gpotter2 commented Aug 8, 2018

This PR is a second (and cleaner) attempt to fix #1484

fixes #1484

@gpotter2 gpotter2 added the bug label Aug 8, 2018
@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 8, 2018

Codecov Report

Merging #1550 into master will increase coverage by 0.21%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##           master    #1550      +/-   ##
==========================================
+ Coverage   85.34%   85.55%   +0.21%     
==========================================
  Files         176      176              
  Lines       40820    41237     +417     
==========================================
+ Hits        34837    35281     +444     
+ Misses       5983     5956      -27
Impacted Files Coverage Δ
scapy/packet.py 76.69% <88.88%> (+0.05%) ⬆️
scapy/layers/tls/record.py 91.22% <0%> (-0.88%) ⬇️
scapy/layers/tls/handshake_sslv2.py 92.01% <0%> (-0.77%) ⬇️
scapy/utils.py 75.97% <0%> (-0.5%) ⬇️
scapy/asn1/ber.py 82% <0%> (-0.29%) ⬇️
scapy/layers/inet.py 69.89% <0%> (+0.16%) ⬆️
scapy/layers/ntp.py 92.3% <0%> (+0.79%) ⬆️
scapy/fields.py 95.03% <0%> (+4.05%) ⬆️

@gpotter2 gpotter2 mentioned this pull request Aug 8, 2018
@guedou
Copy link
Copy Markdown
Member

guedou commented Aug 14, 2018

@p-l- you might want to review that PR.

@guedou
Copy link
Copy Markdown
Member

guedou commented Aug 14, 2018

Unfortunately this does not fix #642 =/

scapy/packet.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice job!

I'd just replace the following lines with (use .pop(), longer / more explicit variable names, _ for unused element):

    for field in self.fields_desc:
        fname = field.name
        try:
            value = fields.pop(fname)
        except KeyError:
            continue
        self.fields[fname] = self.get_field(f).any2i(self, value)
    for fname, _ in fields:
        raise AttributeError(fname)

@p-l- p-l- merged commit a118afc into secdev:master Aug 15, 2018
@gpotter2 gpotter2 deleted the multit-fix branch August 15, 2018 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MultipleTypeField: wrong initialization

4 participants