1diff -urEb dcmtk-3.6.0.orig/dcmnet/libsrc/dulparse.cc dcmtk-3.6.0/dcmnet/libsrc/dulparse.cc
2--- dcmtk-3.6.0.orig/dcmnet/libsrc/dulparse.cc	2010-12-01 09:26:36.000000000 +0100
3+++ dcmtk-3.6.0/dcmnet/libsrc/dulparse.cc	2016-12-02 15:58:49.930540033 +0100
4@@ -393,6 +393,8 @@
5                     return cond;
6
7                 buf += length;
8+                if (presentationLength < length)
9+                  return EC_MemoryExhausted;
10                 presentationLength -= length;
11                 DCMNET_TRACE("Successfully parsed Abstract Syntax");
12                 break;
13@@ -404,12 +406,16 @@
14                 cond = LST_Enqueue(&context->transferSyntaxList, (LST_NODE*)subItem);
15                 if (cond.bad()) return cond;
16                 buf += length;
17+                if (presentationLength < length)
18+                  return EC_MemoryExhausted;
19                 presentationLength -= length;
20                 DCMNET_TRACE("Successfully parsed Transfer Syntax");
21                 break;
22             default:
23                 cond = parseDummy(buf, &length, presentationLength);
24                 buf += length;
25+                if (presentationLength < length)
26+                  return EC_MemoryExhausted;
27                 presentationLength -= length;
28                 break;
29             }
30