{"record":{"id":"18bf79f29c7bdfc9","repo":"QL-Win/QuickLook","slug":"ds-store-root-block-offset-mismatch","errorCode":null,"errorMessage":"DS_Store: root-block offset mismatch","messagePattern":"DS_Store: root-block offset mismatch","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"warning","filePath":"QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs","lineNumber":83,"sourceCode":"        {\n            if (_data.Length < 32)\n                throw new InvalidDataException(\"DS_Store header too short\");\n\n            uint magic1 = ReadUint32BE(_data, (int)_pos);\n            if (magic1 != 1)\n                throw new InvalidDataException(\"DS_Store: wrong magic (expected 0x00000001)\");\n            _pos += 4;\n\n            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);","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs#L65-L101","documentation":"Thrown by DSStoreAllocator.ReadHeader when the root-block offset read at bytes 8-11 does not equal the offset read at bytes 16-19. A valid .DS_Store header stores the root offset twice for consistency; a mismatch signals corruption or a non-standard writer.","triggerScenarios":"Calling GetFileNames on a .DS_Store whose header's two root-offset fields disagree: bit-flip corruption, partial overwrite, an inconsistent third-party writer, or an incomplete write.","commonSituations":"File corrupted in transit or by a disk error; a .DS_Store modified by a non-macOS tool that did not maintain both offset copies; a file from a crashed/aborted macOS write.","solutions":["Catch InvalidDataException and treat the file as unparseable, returning no filenames.","Re-copy the .DS_Store from the original macOS volume.","If you control the writer, ensure both root-offset fields are written atomically.","Validate header consistency before trusting the offsets."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var names = DSStoreExtractor.GetFileNames(path); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"root-block offset mismatch\"))\n{\n    // Header is internally inconsistent; treat as unparseable.\n    names = new List<string>();\n}","preventionTips":["Catch InvalidDataException for corrupt .DS_Store headers and return partial/empty results.","Re-obtain the file from the original macOS volume.","Treat header consistency failures as corruption, not a user error."],"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"}