Skip to content
  • Philip Withnall's avatar
    glocalfileinfo: Increase size of the content-type sniff buffer to 16KiB · 01cdce75
    Philip Withnall authored
    It was previously 4KiB, but this isn’t enough for sniffing the
    content-type of some GPT disk images (they use 4KiB sectors, and the
    magic bytes are in the second sector). A buffer of 8KiB would work,
    but 16KiB seems harmless and more future proof.
    
    Most of the time, the buffer size should be set by xdgmime anyway, based
    on the largest sniff buffer its database needs. Currently (with
    shared-mime-info master) that’s 18730 bytes, so even with a 16KiB buffer
    we’re going to potentially mis-identify a few file types.
    
    Tested manually by modifying the example GPT image from shared-mime-info
    (https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/tests/mime-detection/disk.gpt
    
    )
    to remove the magic at offset 0x200 and add it instead at offset 0x1000,
    then running:
    ```
    cp shared-mime-info.git/tests/mime-detection/disk.gpt ./disk-without-extension
    gio info -a standard::content-type ./disk-without-extension
    ```
    
    It should print `application/vnd.efi.img` rather than
    `application/octet-stream`.
    
    Signed-off-by: default avatarPhilip Withnall <pwithnall@gnome.org>
    
    Fixes: #3186
    01cdce75