Skip to content

Commit

Permalink
recognize JPEG files that do not start with a standard ffd8.ffe0 JFIF…
Browse files Browse the repository at this point in the history
… header
  • Loading branch information
farindk committed Feb 1, 2024
1 parent a28d02f commit 51da10c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@ heif_filetype_result heif_check_filetype(const uint8_t* data, int len)

int heif_check_jpeg_filetype(const uint8_t* data, int len)
{
if (len < 12 || data == nullptr) {
if (len < 4 || data == nullptr) {
return -1;
}

static uint8_t jpeg_signature[12] = {
0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10,
0x4A, 0x46, 0x49, 0x46, 0x00, 0x01
};

return strncmp((const char*) data, (const char*) jpeg_signature, 12) == 0;
return (data[0] == 0xFF &&
data[1] == 0xD8 &&
data[2] == 0xFF &&
(data[3] & 0xF0) == 0xE0);
}


Expand Down

0 comments on commit 51da10c

Please sign in to comment.