{"record":{"id":"44801642aa9abaab","repo":"dotnet/wpf","slug":"invalid-size-specified","errorCode":null,"errorMessage":"Invalid size specified","messagePattern":"Invalid size specified","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs","lineNumber":420,"sourceCode":"        /// <returns>Length of buffer read</returns>\n#endif\n        internal static uint DecodeAsISF(Stream stream, uint cbSize, GuidList guidList, KnownTagCache.KnownTagIndex tag, ref Guid guid, out object data)\n        {\n            uint cb, cbRead = 0;\n            uint cbTotal = cbSize;\n\n            if (0 == cbSize)\n            {\n                throw new InvalidOperationException(SR.EmptyDataToLoad);\n            }\n\n            if (0 == tag) // no tag is passed, it must be embedded in the data\n            {\n                uint uiTag;\n                cb = SerializationHelper.Decode(stream, out uiTag);\n                tag = (KnownTagCache.KnownTagIndex)uiTag;\n                if (cb > cbTotal)\n                    throw new ArgumentException(SR.InvalidSizeSpecified, nameof(cbSize));\n\n                cbTotal -= cb;\n                cbRead += cb;\n                System.Diagnostics.Debug.Assert(guid == Guid.Empty);\n                guid = guidList.FindGuid(tag);\n            }\n\n            if (guid == Guid.Empty)\n            {\n                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage(\"Custom Attribute tag embedded in ISF stream does not match guid table\"), nameof(tag));\n            }\n\n            // Try and find the size\n            uint size = GuidList.GetDataSizeIfKnownGuid(guid);\n\n            if (size > cbTotal)\n                throw new ArgumentException(SR.InvalidSizeSpecified, nameof(cbSize));\n","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs#L402-L438","documentation":"Thrown by CustomAttributeSerializer.DecodeAsISF when the tag-embedded payload claims a compressed data size (cb) larger than the total size (cbSize) available. The declared size cannot fit in the provided buffer, indicating corrupt or mismatched ISF data. It surfaces as ArgumentException with paramName cbSize.","triggerScenarios":"Decoding an ISF custom attribute whose embedded tag block encodes a size exceeding cbSize — typically from corrupted streams, wrong offsets, or mixing data from different ISF payloads.","commonSituations":"Manually slicing byte arrays out of an ISF stream and passing wrong sub-ranges; loading ink written by a different/older ISF writer with incompatible size encoding; partially downloaded or truncated ink files.","solutions":["Verify you are passing the correct byte range/offset to the decode call — the payload must start at the attribute header.","Confirm the ISF data is complete and untruncated (compare against expected total size).","Regenerate the ink data from the original source; the stream is likely corrupt.","Check for version mismatches between the writer of the data and the WPF version decoding it."],"exampleFix":"// before\ncustomAttr = DecodeAsISF(buffer, 0, stream, 0, guid, ref value);\n// after\nif (buffer.Length >= expectedAttrSize) customAttr = DecodeAsISF(buffer, 0, stream, 0, guid, ref value);\nelse throw new InvalidDataException(\"ISF attribute payload truncated\");","handlingStrategy":"validation","validationCode":"if (buffer.Length < declaredSize) throw new InvalidDataException($\"ISF payload too small: have {buffer.Length}, declared {declaredSize}\");","typeGuard":null,"tryCatchPattern":"try { attr = DecodeAsISF(buffer, 0, stream, (uint)buffer.Length, tag, out guid); }\ncatch (ArgumentException ex) { LogCorruption(ex); attr = null; }","preventionTips":["Pass exact byte ranges/offsets into ISF decoders","Checksum or size-verify ink files before load","Regenerate rather than repair corrupt ISF data"],"tags":["ink","isf","deserialization","corrupt-data"],"backgroundTag":"invalid-argument-value","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"}