QL-Win/QuickLook · warning · InvalidDataException
DS_Store: wrong magic (expected 'Bud1')
Error message
DS_Store: wrong magic (expected 'Bud1')
What it means
Thrown by DSStoreAllocator.ReadHeader when bytes 4-7 (big-endian) are not 0x42756431, the ASCII string 'Bud1'. This is the canonical .DS_Store format signature; its absence means the file is not a real .DS_Store B-tree allocator image.
Source
Thrown at QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/DSStore/DSStoreExtractor.cs:76
_root = NewBlock(offset, size);
ReadOffsets();
ReadToc();
ReadFreeList();
}
private (uint offset, uint size) ReadHeader()
{
if (_data.Length < 32)
throw new InvalidDataException("DS_Store header too short");
uint magic1 = ReadUint32BE(_data, (int)_pos);
if (magic1 != 1)
throw new InvalidDataException("DS_Store: wrong magic (expected 0x00000001)");
_pos += 4;
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);View on GitHub (pinned to cb5d9c429c)
Solutions
- Validate the 'Bud1' signature at offset 4 before parsing.
- Skip files that fail the signature check.
- Re-copy the file from the original macOS source.
- Catch InvalidDataException and return an empty list.
Example fix
// before
var names = DSStoreExtractor.GetFileNames(path);
// after
var data = File.ReadAllBytes(path);
if (data.Length < 8 || System.Text.Encoding.ASCII.GetString(data, 4, 4) != "Bud1")
return new List<string>();
var names = DSStoreExtractor.GetFileNames(path); Defensive patterns
Strategy: validation
Validate before calling
// Validate the .DS_Store 'Bud1' signature at offset 4.
public static bool IsValidDsStoreHeader(string path)
{
var data = File.ReadAllBytes(path);
return data.Length >= 8
&& System.Text.Encoding.ASCII.GetString(data, 4, 4) == "Bud1";
} Try / catch
try { var names = DSStoreExtractor.GetFileNames(path); }
catch (InvalidDataException ex) when (ex.Message.Contains("Bud1"))
{
// 'Bud1' signature missing; file is not a valid .DS_Store.
} Prevention
- Validate the 'Bud1' signature at offset 4 before parsing.
- Re-copy the .DS_Store from the macOS source if it fails.
- Catch InvalidDataException and return an empty list.
When it happens
Trigger: Calling GetFileNames on a file whose bytes 4-7 are not 'Bud1': a non-.DS_Store file, a corrupt file, or a file produced by a tool that does not emit the Bud1 signature.
Common situations: Generic binary or text file renamed .DS_Store; corrupt/truncated file from a flaky transfer; a macOS version or third-party tool that writes a different structure.
Related errors
- DS_Store: wrong magic (expected 0x00000001)
- DS_Store header too short
- DS_Store: root-block offset mismatch
- DS_Store: not enough data for block
- DS_Store: block id out of range
AI-assisted analysis of QL-Win/QuickLook@cb5d9c429c (2026-08-13).
Data as JSON: /api/errors/2a52268af97e5799.
Report an issue: GitHub.