Commit 8943637
committed
feat(error): populate decode/encode error offsets from cursor positions
Audit-driven sweep through every call site that passed `0` as the offset
to a decode or encode error producer. Foundation in Devolutions#1266 documented `0`
as the "offset unknown" sentinel; this commit replaces it with a real
cursor position wherever one is in scope.
Coverage: 408 call sites total reviewed via brace-depth enclosing-fn analysis.
- 333 macro-form sites in `invalid_field_err!`, `not_enough_bytes_err!`,
`unexpected_message_type_err!`, `unsupported_version_err!`,
`unsupported_value_err!`, `cast_length!`, `cast_int!` upgraded from
`at: 0` to `in: <cursor>`. The cursor's name comes from the immediate
enclosing function signature (most are `src`, several `dst`, a few
`cursor`, and the BER routines use `stream`).
- 9 direct-function-call sites (`invalid_field_err(...)`,
`unexpected_message_type_err(...)`, `unsupported_value_err(...)`,
`invalid_field_err_with_source(...)`) updated to pass `src.pos()` or
`dst.pos()` from the enclosing decode/encode method.
- The `per_field_err!` helper macro in `ironrdp-pdu/src/mcs.rs` now
takes `in: $cursor` and captures the cursor's position into the
returned closure, so PER read/write failures carry the byte offset
of the field that failed. All 26 callers updated.
- The `validate_dimensions!` and `check_masks_alignment!` local macros
in displaycontrol/pointer now take an explicit `$offset:expr`. Their
call sites pass `0` from constructors and `<cursor>.pos()` from
decode/encode paths.
- 57 sites remain at `at: 0`. These are in `try_from` impls on enum
discriminants, `new`/`with_*` constructors, accessors on already
decoded structs, dimension/size validators, and one `find_size`
helper that takes `&[u8]` and reports byte-0 errors. None of them
have a cursor in scope, so no offset is knowable.
Foundation-crate macros were tightened to enforce the discipline at
compile time:
- `ensure_size!`'s inner offset is now `$buf.pos()` instead of `0`,
enabled by refactoring `encode_string` from `dst: &mut [u8]` to
`dst: &mut WriteCursor<'_>` so the cursor invariant holds for every
caller. The two slice-form callers (`cliprdr/format_data/file_list.rs`
and `rdp/capability_sets/input.rs`) were updated to pass the cursor
directly and use `write_padding!` for fixed-width fields.
- `cast_length!` and `cast_int!` no longer accept a bare form. Callers
must pick `in: <cursor>` to extract the position or `at: <offset>`
to pass one explicitly.
- Doc comments for `cast_length!` and `cast_int!` updated to show the
new in:/at: forms.
Test snapshots that print full `Error` debug output were regenerated
through `UPDATE_EXPECT=1`; the new fixtures now record the real byte
offsets where decode failures originate. Examples: pcb null_size at
offset 4 (after the u32 cbSize read), pcb_v2_string_too_big at 18,
x224 nego_request_unexpected_rdp_msg_type at 35.
The `encode_string` API change is the only user-visible API change in
this commit beyond Devolutions#1266's new error variant fields.
Refs Devolutions#1266, Devolutions#1120.1 parent 45c299f commit 8943637
99 files changed
Lines changed: 790 additions & 791 deletions
File tree
- crates
- ironrdp-ainput/src
- ironrdp-cliprdr-format/src
- ironrdp-cliprdr/src/pdu
- format_data
- ironrdp-core/src
- ironrdp-displaycontrol/src/pdu
- ironrdp-dvc/src
- ironrdp-egfx/src/pdu
- ironrdp-mstsgu/src
- ironrdp-pdu/src
- basic_output
- bitmap
- fast_path
- pointer
- surface_commands
- codecs/rfx
- gcc
- core_data
- input
- rdp
- capability_sets
- bitmap_codecs
- brush
- general
- glyph_cache
- server_license
- client_new_license_request
- client_platform_challenge_response
- licensing_error_message
- server_license_request
- server_platform_challenge
- server_upgrade_license
- session_info
- vc/dvc/gfx
- graphics_messages
- ironrdp-rdpdr/src/pdu
- esc
- ironrdp-rdpsnd/src
- pdu
- ironrdp-server/src/encoder
- ironrdp-str/src
- ironrdp-svc/src
- ironrdp-testsuite-core/tests
- pdu
- str_types
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| |||
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
304 | | - | |
| 305 | + | |
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
320 | | - | |
| 321 | + | |
321 | 322 | | |
322 | 323 | | |
323 | | - | |
| 324 | + | |
324 | 325 | | |
325 | 326 | | |
326 | 327 | | |
| |||
369 | 370 | | |
370 | 371 | | |
371 | 372 | | |
372 | | - | |
| 373 | + | |
373 | 374 | | |
374 | 375 | | |
375 | 376 | | |
| |||
403 | 404 | | |
404 | 405 | | |
405 | 406 | | |
406 | | - | |
| 407 | + | |
407 | 408 | | |
408 | 409 | | |
409 | | - | |
| 410 | + | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
298 | | - | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | 303 | | |
302 | | - | |
| 304 | + | |
303 | 305 | | |
304 | 306 | | |
305 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
| 191 | + | |
193 | 192 | | |
194 | 193 | | |
195 | 194 | | |
| |||
271 | 270 | | |
272 | 271 | | |
273 | 272 | | |
274 | | - | |
| 273 | + | |
275 | 274 | | |
276 | 275 | | |
277 | 276 | | |
| |||
292 | 291 | | |
293 | 292 | | |
294 | 293 | | |
295 | | - | |
| 294 | + | |
296 | 295 | | |
297 | 296 | | |
298 | 297 | | |
299 | | - | |
| 298 | + | |
300 | 299 | | |
301 | 300 | | |
302 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
| 395 | + | |
395 | 396 | | |
396 | 397 | | |
397 | 398 | | |
| |||
449 | 450 | | |
450 | 451 | | |
451 | 452 | | |
452 | | - | |
| 453 | + | |
453 | 454 | | |
454 | 455 | | |
455 | 456 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
0 commit comments