P2: later
An appendix to the milestone.
P2: worth doing, not blocking
-
lentruncates on a target whoseusizeis narrower than 32 bits. Finding:(w0 & 0xffff_ffff) as usizedrops the high half of the count on a 16-bit target, so a first word claiming0x1_0010bytes reads as 16 and passesunpack's bound. No target the crate names has the problem (all three are 64-bit).unpackwould still copy only sixteen bytes into a sixteen-byte buffer, so the consequence is a wrong count and not a wrong read. The same class as milestone 1048 (what an outside maintainer would fix before 0.1.0)'s item 2. Evidence:src/lib.rslines 83 to 85 and 235 to 238. Change: compare the count inu64insideunpackbefore casting, orusize::try_fromwith a failure reading asMalformed. Door: two-way. Effort: XS. -
reqsilently discards an opcode above 255 or a count aboveu32::MAX. Finding:operation << 56keeps eight bits andlen & 0xffff_ffffkeeps thirty-two, soreq(256, 0)is the zero word, a valid empty bytes message. No caller passes such values; the function isconstandpub, and an outside writer may. Evidence:src/lib.rslines 72 to 75. Change: typed parameters,operation: u8andlen: u32, so the type system refuses what the masks hide; the two masks become casts. Every call site in the tree passes literals or values that fit. Door: two-way (signature, before any release). Effort: XS. -
packreturns a bare four-tuple. Finding:(u64, u64, u64, usize)at 31 call sites, each destructured as(w0, w1, w2, n). A reader of a call site learns the meaning from the destructuring pattern and not from the type. Evidence:src/lib.rsline 132; everypackcaller. Change: aCopystruct for the three words (its name is the architect's;Wordswith fieldsfirst,second,thirdis one shape) returned besidetaken, andunpacktaking the same struct. A convenience and a door the architect may decline; the tuple is not wrong. Door: one-way at release (a public type) if taken. Leaving it loses nothing. Effort: M (call sites). -
The two equivalent mutants need exemptions in the new repository. Finding:
pack's<to<=andreq's|to^survive, and the census classifies them equivalent. The census also listswith_severity's>to>=and|to^, equivalent for the same reasons: the mask applies before the or, and 7 clamps to 7. Without entries in.github/mutants-exemptsthe weeklymutationverdict is red. Evidence:notes/project-metrics/mutation-survivor-classes.csvlines 13 to 16;notes/mutation-testing/baseline-survivors-grant-plan-to-swish.mdlines 224 to 231. Change: the exemptions with one reason each, carried over from the survivor note. Door: two-way. Effort: XS. -
with_severityandseverityapply to any first word, including an end-of-stream word. Finding: both docs say they act on "a bytes message's" first word, and neither checks the opcode.with_severity(eof(), 3)is a well-formedEofwith severity bits set, which no consumer reads. Harmless today; worth one sentence so an implementer does not look for meaning there. Evidence:src/lib.rslines 171 to 188. Change: one sentence in each doc comment: a consumer reads the bits only on a bytes message. Door: two-way. Effort: XS.