{"record":{"id":"d16ff13df7989f09","repo":"dotnet/wpf","slug":"extendedproperty-decoded-totalbytesinstrokeblockofisfstream","errorCode":null,"errorMessage":"ExtendedProperty decoded totalBytesInStrokeBlockOfIsfStream exceeded ISF stream totalBytesInStrokeBlockOfIsfStream","messagePattern":"ExtendedProperty decoded totalBytesInStrokeBlockOfIsfStream exceeded ISF stream totalBytesInStrokeBlockOfIsfStream","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs","lineNumber":320,"sourceCode":"                            object data;\n                            Guid guid = guidList.FindGuid(tag);\n                            if (guid == Guid.Empty)\n                            {\n                                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Stroke Custom Attribute tag embedded in ISF stream does not match guid table\"));\n                            }\n\n                            // load the extended property data from the stream (and decode the type)\n                            locallyDecodedBytes = ExtendedPropertySerializer.DecodeAsISF(stream, remainingBytesInStrokeBlock, guidList, tag, ref guid, out data);\n\n                            // add the guid/data pair into the property collection (don't redecode the type)\n                            if (extendedProperties == null)\n                            {\n                                extendedProperties = new ExtendedPropertyCollection();\n                            }\n                            extendedProperties[guid] = data;\n                            if (locallyDecodedBytes > remainingBytesInStrokeBlock)\n                            {\n                                throw new InvalidOperationException(StrokeCollectionSerializer.ISFDebugMessage(\"ExtendedProperty decoded totalBytesInStrokeBlockOfIsfStream exceeded ISF stream totalBytesInStrokeBlockOfIsfStream\"));\n                            }\n\n                            remainingBytesInStrokeBlock -= locallyDecodedBytes;\n                        }\n                        break;\n                }\n            }\n\n            if (0 != remainingBytesInStrokeBlock)\n                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Invalid ISF data\"));\n\n            return totalBytesInStrokeBlockOfIsfStream;\n        }\n#if OLD_ISF\n        /// <summary>\n        /// Loads packets from the input stream.  For example, packets are all of the x's in a stroke\n        /// </summary>\n#else","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs#L302-L338","documentation":"Thrown by StrokeSerializer.DecodeISFIntoStroke when an extended property decoded by ExtendedPropertySerializer.DecodeAsISF consumed more bytes (locallyDecodedBytes) than remain in the stroke block (remainingBytesInStrokeBlock). This is an internal consistency check against oversized/lying property-length headers in the ISF stream.","triggerScenarios":"Deserializing ISF whose extended-property block declares/decodes more bytes than the enclosing stroke block contains — corrupt files, hand-crafted ISF with mismatched size fields, or a decoder/producer mismatch on property encoding.","commonSituations":"Loading damaged ink files; ISF from third-party writers that over-report property sizes; concatenated or sliced ISF streams whose block boundaries don't line up.","solutions":["Validate the ISF stream structure (block sizes consistent, no truncation) before deserializing","Re-export the ink from the producing application instead of decoding the inconsistent stream","Catch InvalidOperationException around Deserialize and recover by rebuilding strokes from raw packet data or a backup","If generating ISF, ensure ExtendedPropertySerializer-encoded sizes match the bytes actually written into the stroke block"],"exampleFix":"// before\ntry { scs.Deserialize(corruptIsf); } // InvalidOperationException on size overrun\n// after\ntry { scs.Deserialize(corruptIsf); }\ncatch (InvalidOperationException ex) {\n    log.Warn(\"ISF extended property size mismatch\", ex);\n    strokeCollection = LoadFromBackup() ?? new StrokeCollection();\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"try { scs.Deserialize(isfStream); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"exceeded ISF stream\")) {\n    log.Warn(\"ISF extended property size overrun\", ex);\n    strokeCollection = LoadFromBackup() ?? new StrokeCollection();\n}","preventionTips":["Write ISF only via WPF serializer APIs so encoded sizes match written bytes","Validate ISF block-size consistency before loading untrusted files","Keep backups of ink objects in memory/XML so corrupt ISF can be discarded"],"tags":["ink","isf","deserialization","size-mismatch","corrupt-input"],"backgroundTag":"invalid-argument-format","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}