Skip to content

finfo::buffer(): Failed identify data 0:(null) #13344

Closed

Description

@P2T

Description

The following code:

<?php
$data = pack('H*','fffe000000099999');
$mime_type = (new finfo(FILEINFO_MIME))->buffer($data);

Resulted in this output:

Warning: finfo::buffer(): Failed identify data 0:(null)

But I expected this output instead:
Something instead of '(null)'

PHP Version

PHP 8.3.2

Operating System

No response

Activity

  1. Girgias commented on Feb 7, 2024

    @Girgias
    Member

    I'm confused, why do you expect "something instead of null" here?

    What does this data represent and how should it determined?

    Anyway, this looks more like a feature request for the underling libmagic library: https://www.darwinsys.com/file/ or https://bugs.astron.com/my_view_page.php

  2. P2T commented on Feb 7, 2024

    @P2T
    Author

    I'm confused, why do you expect "something instead of null" here?

    What does this data represent and how should it determined?

    Anyway, this looks more like a feature request for the underling libmagic library: https://www.darwinsys.com/file/ or https://bugs.astron.com/my_view_page.php

    I don't know the file format. The issue is the warning with the message "null".

    Proposal 1: remove the warning, return false

    Proposal 2: keep the warning, change (null) to a default message

    Proposal 3: keep the warning, show an actual/useful message from the lib (only in this case, this ticket could be considered as a feature request for the lib).

  3. ranvis commented on Feb 8, 2024

    @ranvis
    Contributor

    @Girgias
    The current libmagic (5.45) contains the update that fixes this case: file/file@029b824.

    It appears that the identification error without error code/message is just the bug of the library.
    Otherwise, error code and message should be returned from the library, as the manpage says magic_buffer() returns NULL on error.

  4. ndossche commented on Feb 11, 2024

    @ndossche
    Member

    Thanks for figuring out the upstream commit.
    I'll get it backported. Additionally, I prepared a PR to update 8.4-dev to libmagic 5.45.

  5. added a commit that references this issue on Feb 11, 2024
    61e0968
  6. added 2 commits that reference this issue on Feb 13, 2024
    c2b671c
    e71b597
  7. added a commit that references this issue on Feb 13, 2024
    be34b96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions