{"record":{"id":"d36f13c32e826a00","repo":"QL-Win/QuickLook","slug":"ds-store-not-enough-data-for-block","errorCode":null,"errorMessage":"DS_Store: not enough data for block","messagePattern":"DS_Store: not enough data for block","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"warning","filePath":"QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs","lineNumber":92,"sourceCode":"            uint magic = ReadUint32BE(_data, (int)_pos);\n            if (magic != 0x42756431u)\n                throw new InvalidDataException(\"DS_Store: wrong magic (expected 'Bud1')\");\n            _pos += 4;\n\n            uint offset = ReadUint32BE(_data, (int)_pos); _pos += 4;\n            uint size   = ReadUint32BE(_data, (int)_pos); _pos += 4;\n            uint offset2 = ReadUint32BE(_data, (int)_pos);\n            if (offset != offset2)\n                throw new InvalidDataException(\"DS_Store: root-block offset mismatch\");\n            _pos += 4;\n\n            return (offset, size);\n        }\n\n        private DSStoreBlock NewBlock(uint pos, uint size)\n        {\n            if (_data.Length < pos + 4 + size)\n                throw new InvalidDataException(\"DS_Store: not enough data for block\");\n            var buf = new byte[size];\n            Buffer.BlockCopy(_data, (int)pos + 4, buf, 0, (int)size);\n            return new DSStoreBlock(this, pos, size, buf);\n        }\n\n        private void ReadOffsets()\n        {\n            uint count = _root.ReadUint32();\n            _root.Skip(4);\n            for (int offcount = (int)count; offcount > 0; offcount -= 256)\n            {\n                for (int i = 0; i < 256; i++)\n                {\n                    uint val = _root.ReadUint32();\n                    if (val != 0)\n                        _offsets.Add(val);\n                }\n            }","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs#L74-L110","documentation":"Thrown by DSStoreAllocator.NewBlock when the declared block (at position pos with 4-byte header + size bytes) extends beyond the available data buffer. This means the root block or a referenced block claims a size/offset that the file cannot satisfy.","triggerScenarios":"During DSStoreAllocator construction (root block) or GetBlock (referenced blocks), the computed pos+4+size exceeds _data.Length: corrupt offset table, truncated file, or a malformed block descriptor.","commonSituations":"A truncated .DS_Store where the tail was cut off; a corrupt offset/size in the TOC or offset table; a file assembled from mismatched fragments.","solutions":["Catch InvalidDataException during GetFileNames and return an empty/partial filename list.","Re-obtain the .DS_Store from the source.","Before parsing, sanity-check that the file size is consistent with the header's root offset/size.","Log the offending block offset/size to aid diagnosis."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var names = DSStoreExtractor.GetFileNames(path); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"not enough data for block\"))\n{\n    // A referenced block extends beyond the file; return partial results.\n    names = new List<string>();\n}","preventionTips":["Catch InvalidDataException during .DS_Store parsing and return partial filenames.","Re-copy the file from the macOS source.","Sanity-check the header's root offset/size against the actual file length."],"tags":["dsstore","macos","binary-format","corruption","invaliddata","csharp"],"backgroundTag":null,"analyzedSha":"cb5d9c429c81d9796fac469da2a68efb5626946d","analyzedAt":"2026-08-13T11:51:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}