diff options
-rwxr-xr-x | tests/file.test | 3 | ||||
-rw-r--r-- | toys/posix/file.c | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/tests/file.test b/tests/file.test index 4b7b5a9e..90acfa4c 100755 --- a/tests/file.test +++ b/tests/file.test @@ -35,6 +35,9 @@ testing "7z file" "file $FILES/tar/tar.7z | sed 's|$FILES/||'" \ "tar/tar.7z: 7-zip archive data, version 0.4\n" "" "" testing "zip file" "file $FILES/zip/example.zip | sed 's|$FILES/||'" \ "zip/example.zip: Zip archive data, requires at least v1.0 to extract\n" "" "" +echo R0lGODlhIAAgAMZHAAAAABYWFiYmJioqKi4uLjIy | base64 -d > gif +testing "gif file" "file gif" "gif: GIF image data, 32 x 32\n" "" "" +rm -f gif # TODO: check in a genuine minimal .dex testing "Android .dex" "file android.dex" "android.dex: Android dex file, version 035\n" "" "" diff --git a/toys/posix/file.c b/toys/posix/file.c index a1de9168..6fa51102 100644 --- a/toys/posix/file.c +++ b/toys/posix/file.c @@ -226,7 +226,7 @@ static void do_regular_file(int fd, char *name) // https://www.w3.org/Graphics/GIF/spec-gif89a.txt } else if (len>16 && (strstart(&s, "GIF87a") || strstart(&s, "GIF89a"))) xprintf("GIF image data, %d x %d\n", - (int)peek_le(s, 2), (int)peek_le(s+8, 2)); + (int)peek_le(s, 2), (int)peek_le(s+2, 2)); // TODO: parsing JPEG for width/height is harder than GIF or PNG. else if (len>32 && !memcmp(toybuf, "\xff\xd8", 2)) xputs("JPEG image data"); |