Repository navigation
fix(corekit): a length-less SchemaField passes -1 to its schema, so every list item warns 'packet length < 0' - #1157
Conversation
|
Cross-review verdict on The note at Everything else checks out:
|
…very list item warns 'packet length < 0' SchemaField.unpack passed its "undeclared" length of -1 on to the nested schema, seeding __length__ negative, so every sub-field of every item warned. It now measures the remainder of the buffer and passes that as a declared length. Passing None instead would let prepare() turn an exhausted buffer into its quiet StreamEOFError, ending an extraction on a truncated item; a declared zero keeps that a FieldValueError as before. Closes #1148
1e78f8a to
e233a73
Compare
|
Cross-review verdict on The reviewer's round 1 was GOOD TO GO with the stale
|
|
Coverage: 88.75% (unit tier, Python 3.14,
Per-file detail: the |
Please follow the guide below
make pylint,make mypy,make isort) — run on the touched files: isort clean; mypy/pylint report nothing in the changed linesmake testpasses, and a test case covers the change — only the modules listed below, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1148.
SchemaField.unpackpassed its "undeclared"-1on as the nested schema's length, so__length__started negative and every sub-field warned. It now measures what is left in the buffer and passes that as a declared length. PassingNonewould be simpler, butprepare()would then turn a buffer that has run out into its quietStreamEOFError("end of capture"). Measured: that would change a truncated LOCATOR_SET fromFieldValueErrortoStreamEOFError. Fixed-length items are unchanged.Also rewrites the stale
ContextRequestOptionnote inpcapkit/protocols/schema/internet/mh.py(docstring only; code AST unchanged), which justified the opaquerequestsrun with the-1warnings this PR removes. The opaque run is kept because a nested-schema list would only warn on an entry that overruns the option and zero-pad its value, whereMH._read_opt_crraisesProtocolError.SchemaWarningcount)FieldValueError+ 17FieldValueError+ 6FieldValueError+ 11FieldValueError+ 7New
tests/corekit/test_fields_misc_schema_length_1148_unit.py: 5 passed. Without the fix, 3 tests fail (5 subfailures). With theNonevariant, the truncation test fails withStreamEOFError. Passing (one module per process):test_fields_misc,_misc_packet_context,_collections,_field,test_option_roundtrip_unit,test_hip_unit,test_hip_locator_set_length_unit,test_mh_unit,test_ipv4_unit,test_httpv2_payload_length_unit, plustests/project(385 passed, 1 skipped).