Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading partial objects #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akaraivanov
Copy link

This PR fixes reading DcmFileFormat when object is only partially available in input stream.

…a info

Use case:
* DcmFileFormat::readUntilTag() (called from DcmFileFormat::read())
  tries to read DcmMetaInfo which is partially available in input
  stream
* DcmMetaInfo::read() returns EC_StreamNotifyClient
* DcmFileFormat::readUntilTag() does not check the returned condition
  and tries to use DcmMetaInfo (by calling lookForXfer()) even though
  the object is not completely read. By using it, DcmFileFormat
  changes meta info's current elemetnt to have index -1.
* next time DcmFileFormat::readUntilTag() is called, it tries to finish
  reading last incomplete object. Having its current index set to -1
  that leads to a crash

Fix:
* check returned condition from DcmMetaInfo::read() and exit early
  if it is bad
Use case:
* DcmMetaInfo::read() is called to read object which is partially
  available in input stream
* Transfer syntax is detected from the preamble and is stored in
  member variable Xfer
* On the second call to DcmMetaInfo::read() the stored transfer syntax is
  overwritten with the value of the input transfer syntax (typically EXS_Unknown).
  This time preamble is already read and is not used to detect transfer syntax.
  If input parameter is equal to EXS_Unknown current transfer syntax
  is maintained in local vairable newxfer will also be EXS_Unknown.
  Calling readGroupLength() with EXS_Unknown will return condition
  EC_IllegalCall and that is the be also the returned value of
  DcmMetaInfo::read()

Fix:
* do not overwrite store transfer syntax in Xfer if object's transfer has started
* use stored transfer syntax on consecutive calls
@jriesmeier
Copy link
Member

Thank you. We've added this issue to out to-do list so it doesn't get lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants