-
-
Notifications
You must be signed in to change notification settings - Fork 36
protocols: drop ipv6_opts' stray SMF_DPD test field, fix two length underflows #449
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
Changes from all commits
7b7337b
aa0ef0b
d60916b
8e31683
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,27 @@ def mpl_opt_seed_id_len(pkt: 'dict[str, Any]') -> 'int': | |
| raise FieldValueError(f'IPv6-Opts: invalid MPL Seed-ID type: {s_type}') | ||
|
|
||
|
|
||
| def smf_i_dpd_id_len(pkt: 'dict[str, Any]') -> 'int': | ||
|
JarryShaw marked this conversation as resolved.
|
||
| """Return SMF I-DPD identifier length. | ||
|
|
||
| Args: | ||
| pkt: SMF identification-based DPD option unpacked schema. | ||
|
|
||
| Returns: | ||
| SMF I-DPD identifier length. | ||
|
|
||
| Raises: | ||
| FieldValueError: If ``Opt Data Len`` on the wire is too short to hold | ||
| the TaggerID it declares, which would otherwise underflow the | ||
| identifier length below zero. | ||
|
|
||
| """ | ||
| length = pkt['len'] - (1 if pkt['info']['type'] == 0 else (pkt['info']['len'] + 2)) | ||
| if length < 0: | ||
| raise FieldValueError(f'IPv6-Opts: invalid SMF I-DPD option length: {pkt["len"]}') | ||
| return length | ||
|
|
||
|
|
||
| def smf_dpd_data_selector(pkt: 'dict[str, Any]') -> 'Field': | ||
| """Selector function for :attr:`_SMFDPDOption.data` field. | ||
|
|
||
|
|
@@ -431,9 +452,6 @@ class SMFDPDOption(Option, EnumSchema[Enum_SMFDPDMode]): | |
| class SMFIdentificationBasedDPDOption(SMFDPDOption, code=Enum_SMFDPDMode.I_DPD): | ||
| """Header schema for IPv6-Opts SMF identification-based DPD options.""" | ||
|
|
||
| test: 'SMFDPDTestFlag' = ForwardMatchField(BitField(length=1, namespace={ | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the PR's note reads like the ForwardMatchField's logic or handling logic is defect. maybe worth double checking and fixing.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, and it is a defect in its own right — filed as #446, deliberately kept out of this PR. Two separate faults meet at this line, and I want to be clear which is which because only one of them is fixed here. What this PR fixes is a real defect independent of What you're pointing at is the reason the stray field had teeth, and it is the shared machinery. Why deleting the field cannot be the general fix. The CGA Parameters option is the case that proves it: public_key_test: 'ANSIKeyLengthTest' = ForwardMatchField(BitField(length=2, namespace={'len': (8, 8)}))and that one is load-bearing — the public key's length genuinely has to be read before the key can be sized, so it cannot be deleted. With the other blocker in that path fixed (#445, a nested schema being unable to reach the enclosing packet's fields), the same option then fails at So #446 is the root and it needs answering, but it is a design question rather than a one-line fix, which is why it is its own issue rather than folded in here. I've dispatched work on #446 now — the sequencing reason for holding it back was that this PR was already reasoning about This PR stays as-is: it deletes a field that should never have been there, and #446 fixes why its presence broke anything. Happy to fold #446 in here instead if you'd rather see them land together — say so and I'll re-scope rather than open a second PR. |
||
| 'mode': (0, 1), | ||
| })) | ||
| #: TaggerID information. | ||
| info: 'TaggerIDInfo' = BitField(length=1, namespace={ | ||
| 'mode': (0, 1), | ||
|
|
@@ -446,9 +464,7 @@ class SMFIdentificationBasedDPDOption(SMFDPDOption, code=Enum_SMFDPDMode.I_DPD): | |
| lambda pkt: pkt['info']['type'] != 0, | ||
| ) | ||
| #: Identifier. | ||
| id: 'bytes' = BytesField(length=lambda pkt: pkt['len'] - ( | ||
| 1 if pkt['info']['type'] == 0 else (pkt['info']['len'] + 2) | ||
| )) | ||
| id: 'bytes' = BytesField(length=smf_i_dpd_id_len) | ||
|
|
||
| def post_process(self, packet: 'dict[str, Any]') -> 'SMFIdentificationBasedDPDOption': | ||
| """Revise ``schema`` data after unpacking process. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.