Skip to content

Commit 32f0c40

Browse files
committed
Fix error pile-ups reading truncated PixelData
1 parent 73b1367 commit 32f0c40

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/dicom-parse.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,10 @@ bool dcm_parse_pixeldata_offsets(DcmError **error,
940940
*first_frame_offset = position;
941941

942942
// the next thing should be the tag for frame 1
943-
if (!read_tag(&state, &tag, &position) ||
944-
tag != TAG_ITEM) {
943+
if (!read_tag(&state, &tag, &position)) {
944+
return false;
945+
}
946+
if (tag != TAG_ITEM) {
945947
dcm_error_set(error, DCM_ERROR_CODE_PARSE,
946948
"Reading Basic Offset Table failed",
947949
"Basic Offset Table too large");
@@ -990,8 +992,10 @@ bool dcm_parse_pixeldata_offsets(DcmError **error,
990992
}
991993

992994
// the next thing should be the end of sequence tag
993-
if (!read_tag(&state, &tag, &position) ||
994-
tag != TAG_SQ_DELIM) {
995+
if (!read_tag(&state, &tag, &position)) {
996+
return false;
997+
}
998+
if (tag != TAG_SQ_DELIM) {
995999
dcm_error_set(error, DCM_ERROR_CODE_PARSE,
9961000
"Reading Basic Offset Table failed",
9971001
"Too many frames in PixelData");

0 commit comments

Comments
 (0)