Skip to content

Validate fixed PDU lengths and encoded item length overflow#799

Open
atlex00 wants to merge 1 commit into
Enet4:mainfrom
atlex00:fix/ul-pdu-length-validation
Open

Validate fixed PDU lengths and encoded item length overflow#799
atlex00 wants to merge 1 commit into
Enet4:mainfrom
atlex00:fix/ul-pdu-length-validation

Conversation

@atlex00

@atlex00 atlex00 commented Jun 22, 2026

Copy link
Copy Markdown

read_pdu accepted the fixed-size A-ASSOCIATE-RJ, A-RELEASE-RQ, A-RELEASE-RP, and A-ABORT PDUs with declared lengths other than 4, silently ignoring trailing bytes. The chunk writers also cast lengths with as u16/as u32, so oversized items could wrap and emit invalid length fields.

DICOM PS3.8 fixes these PDU-length fields at 00000004H (§9.3.4, §9.3.6, §9.3.7, §9.3.8) and defines item/PDU length fields as exact lengths. This requires pdu_length == 4 for those fixed PDUs on read, replaces the length casts with checked conversions that error on overflow, and adds the corresponding read/write error variants.

@atlex00 atlex00 force-pushed the fix/ul-pdu-length-validation branch from 3205ae4 to 5d1e32f Compare June 22, 2026 23:49
@atlex00 atlex00 marked this pull request as ready for review June 22, 2026 23:54
@atlex00 atlex00 marked this pull request as draft June 29, 2026 11:11
@atlex00

This comment was marked as resolved.

@atlex00 atlex00 force-pushed the fix/ul-pdu-length-validation branch from 5d1e32f to 15fd94d Compare June 29, 2026 11:18
@atlex00 atlex00 force-pushed the fix/ul-pdu-length-validation branch from 15fd94d to 056ca0d Compare June 29, 2026 12:06
@atlex00 atlex00 marked this pull request as ready for review June 29, 2026 21:48
@Enet4 Enet4 added A-lib Area: library C-ul Crate: dicom-ul labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lib Area: library C-ul Crate: dicom-ul

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants