Skip to content

fix _packet_subnet calculation logic#4943

Open
wenxuan70 wants to merge 2 commits intosecdev:masterfrom
wenxuan70:bugfix/_pack_subnet
Open

fix _packet_subnet calculation logic#4943
wenxuan70 wants to merge 2 commits intosecdev:masterfrom
wenxuan70:bugfix/_pack_subnet

Conversation

@wenxuan70
Copy link
Contributor

Checklist:

  • [ x ] If you are new to Scapy: I have checked CONTRIBUTING.md (esp. section submitting-pull-requests)
  • [ x ] I squashed commits belonging together
  • [ x ] I added unit tests or explained why they are not relevant
  • [ x ] I executed the regression tests (using tox)
  • [ x ] If the PR is still not finished, please create a Draft Pull Request

fixes #4942

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.30%. Comparing base (dbaaf69) to head (923b03d).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
scapy/layers/dns.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4943      +/-   ##
==========================================
+ Coverage   80.28%   80.30%   +0.02%     
==========================================
  Files         375      379       +4     
  Lines       92431    93099     +668     
==========================================
+ Hits        74205    74761     +556     
- Misses      18226    18338     +112     
Files with missing lines Coverage Δ
scapy/layers/dns.py 83.55% <85.71%> (-0.07%) ⬇️

... and 18 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gpotter2
Copy link
Member

Hi and thanks for the PR ! It seems that it broke certain test cases, could you take a look?

Thanks

@wenxuan70
Copy link
Contributor Author

Thanks for letting me know! I'll look into the failing tests and get back to you soon.

MultipleTypeField(
[(ClientSubnetv4("address", "192.168.0.0",
length_from=lambda p: p.source_plen),
length_from=lambda p: p.source_plen or 16),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default value of 16 here is to maintain backward compatibility: when scope_plen is None, the original _pack_subnet method computes 16 bits from the default address 192.168.0.0.

@wenxuan70 wenxuan70 force-pushed the bugfix/_pack_subnet branch from 9af0e85 to f8db4f5 Compare March 20, 2026 15:56
@wenxuan70 wenxuan70 force-pushed the bugfix/_pack_subnet branch from f8db4f5 to 923b03d Compare March 20, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_pack_subnet method will lose 1 byte when converting 101.132.0.0/23 to bytes

2 participants