Skip to content

Commit 3ecdf43

Browse files
Add checks for 1-bit (unimplemented) or non-mod-8 (invalid) BitsAllocated.
8.1.1 Pixel Data Encoding of Related Data Elements Bits Allocated (0028,0100) shall either be 1, or a multiple of 8. https://dicom.nema.org/medical/dicom/current/output/html/part05.html#PS3.5
1 parent 8bec49d commit 3ecdf43

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/dicom-file.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,18 @@ static bool set_pixel_description(DcmError **error,
743743
!dcm_element_get_value_integer(error, element, 0, &value)) {
744744
return false;
745745
}
746+
if (value == 1) {
747+
dcm_error_set(error, DCM_ERROR_CODE_INVALID,
748+
"reading frame item failed",
749+
"1-bit pixel storage (Bits Allocated == 1) not implemented");
750+
return false;
751+
}
752+
if (value % 8 != 0) {
753+
dcm_error_set(error, DCM_ERROR_CODE_INVALID,
754+
"reading frame item failed",
755+
"BitsAllocated must be a multiple of 8");
756+
return false;
757+
}
746758
desc->bits_allocated = (uint16_t) value;
747759

748760
element = dcm_dataset_get(error, metadata, 0x00280101);

0 commit comments

Comments
 (0)