Commit 0a7c090
committed
fix(nfc): bounds-check slicing flagged by clippy::indexing_slicing
The NFC backend (gated behind the `nfc`/`pcsc`/`libnfc` features) was
not exercised by the default `cargo build`, so the lint enabled in
the previous commits did not surface there. CI's
`cargo clippy --all-targets --all-features` flags 5 sites:
- `channel::NfcChannel::handle`: replace `&buf[..len]` (returned by
`handle_in_ctx` into a fixed 1024-byte buffer) with `buf.get(..len)`
and surface `HandleError::NotEnoughBuffer` if a backend overruns.
- `channel::NfcChannel::cbor_send`: replace the `&rest[..250]` /
`&rest[250..]` chunking with `rest.split_at(250)`; the
`rest.len() > 250` loop predicate keeps this panic-safe.
- `libnfc::Channel::connect_to_target`: replace
`&modulations[modulations.len() - 1]` with `.last()`, returning
`TransportUnavailable` if the device reports no supported baud rates.1 parent 8697517 commit 0a7c090
2 files changed
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | | - | |
| 209 | + | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
275 | | - | |
276 | | - | |
| 277 | + | |
| 278 | + | |
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| |||
0 commit comments