QL-Win/QuickLook · warning · InvalidDataException

DS_Store: not enough data for block

Error message

DS_Store: not enough data for block

What it means

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.

Source

Thrown at QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs:92

            uint magic = ReadUint32BE(_data, (int)_pos);
            if (magic != 0x42756431u)
                throw new InvalidDataException("DS_Store: wrong magic (expected 'Bud1')");
            _pos += 4;

            uint offset = ReadUint32BE(_data, (int)_pos); _pos += 4;
            uint size   = ReadUint32BE(_data, (int)_pos); _pos += 4;
            uint offset2 = ReadUint32BE(_data, (int)_pos);
            if (offset != offset2)
                throw new InvalidDataException("DS_Store: root-block offset mismatch");
            _pos += 4;

            return (offset, size);
        }

        private DSStoreBlock NewBlock(uint pos, uint size)
        {
            if (_data.Length < pos + 4 + size)
                throw new InvalidDataException("DS_Store: not enough data for block");
            var buf = new byte[size];
            Buffer.BlockCopy(_data, (int)pos + 4, buf, 0, (int)size);
            return new DSStoreBlock(this, pos, size, buf);
        }

        private void ReadOffsets()
        {
            uint count = _root.ReadUint32();
            _root.Skip(4);
            for (int offcount = (int)count; offcount > 0; offcount -= 256)
            {
                for (int i = 0; i < 256; i++)
                {
                    uint val = _root.ReadUint32();
                    if (val != 0)
                        _offsets.Add(val);
                }
            }

View on GitHub (pinned to cb5d9c429c)

Solutions

  1. Catch InvalidDataException during GetFileNames and return an empty/partial filename list.
  2. Re-obtain the .DS_Store from the source.
  3. Before parsing, sanity-check that the file size is consistent with the header's root offset/size.
  4. Log the offending block offset/size to aid diagnosis.
Defensive patterns

Strategy: try-catch

Try / catch

try { var names = DSStoreExtractor.GetFileNames(path); }
catch (InvalidDataException ex) when (ex.Message.Contains("not enough data for block"))
{
    // A referenced block extends beyond the file; return partial results.
    names = new List<string>();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of QL-Win/QuickLook@cb5d9c429c (2026-08-13). Data as JSON: /api/errors/d36f13c32e826a00. Report an issue: GitHub.