From ad781fd82829b0173ad556dbce59f92f6cbbd54f Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Tue, 13 Sep 2022 14:41:52 +0200 Subject: [PATCH] Handle another invalid case --- Source/MediaStorageAndFileFormat/gdcmCleaner.cxx | 7 +++++++ Utilities/gdcmext/csa.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/MediaStorageAndFileFormat/gdcmCleaner.cxx b/Source/MediaStorageAndFileFormat/gdcmCleaner.cxx index f58691cdc..03912d1dd 100644 --- a/Source/MediaStorageAndFileFormat/gdcmCleaner.cxx +++ b/Source/MediaStorageAndFileFormat/gdcmCleaner.cxx @@ -761,11 +761,18 @@ static bool CleanCSA(DataSet &ds, const DataElement &de) { if (bv->GetLength() >= 10 && memcmp(bv->GetPointer(), psd_ocm, 10) == 0) { return true; } + // ANGIOHEAD case. This is a DICOM Explicit with a odd ending: static const char end[] = "END! "; if (bv->GetLength() >= 10 && memcmp(bv->GetPointer() + bv->GetLength() - 10, end, 10) == 0) { return true; } + // byte-swapped ANGIOHEAD + static const char ned[] = "NE!D "; + if (bv->GetLength() >= 10 && + memcmp(bv->GetPointer() + bv->GetLength() - 10, ned, 10) == 0) { + return true; + } const bool zero = isAllZero(bv->GetPointer(), bv->GetLength()); if (zero) return true; diff --git a/Utilities/gdcmext/csa.c b/Utilities/gdcmext/csa.c index 65df50f20..da9757d95 100644 --- a/Utilities/gdcmext/csa.c +++ b/Utilities/gdcmext/csa.c @@ -146,7 +146,7 @@ static bool read_magic(struct app *self) { magic = NOMAGIC; } else if (n == 0x7364703c && unused == 0x6f633c3e) // aka '