Skip to content

Instantly share code, notes, and snippets.

@kriskowal
Created October 19, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriskowal/f25c81725f0d5c98d41c1e6b7ee8f8fe to your computer and use it in GitHub Desktop.
Save kriskowal/f25c81725f0d5c98d41c1e6b7ee8f8fe to your computer and use it in GitHub Desktop.
Debugging a zip library refactor. The bug was a uint32 where a uint16 belonged.
00000000: 504b 0304 0a00 0000 0000 3514 5151 849e PK........5.QQ..
^^^^ ^^^^ LOCAL_FILE_HEADER
^^^^ version 10
^^^^ bitFlag
^^^^ compression method
^^^^ ^^^^ date
00000010: e8b4 0e00 0000 0e00 0000 0900 0000 6865 ..............he
^^^^ crc32
^^^^ ^^^^ compressed size (14)
^^^^ ^^^^ uncompressed size (14)
^^^^ file name length (hello.txt) 9
^^^^ extra fields length
^^^^
00000020: 6c6c 6f2e 7478 7448 656c 6c6f 2c20 576f llo.txtHello, Wo
^^^^ ^^^^ ^^^^ ^^ file name
^^ ^^^^ ^^^^ ^^^^ ^^^^
00000030: 726c 6421 0a50 4b01 021e 030a 0000 0000 rld!.PK.........
^^^^ ^^^^ ^^ file content (14)
^^ ^^^^ ^^ CENTRAL_FILE_HEADER
^^ file version (30)
^^ file made by (3)
>> headers
^^ ^^ version 10
^^ ^^ bitFlag
^^
00000040: 0035 1451 5184 9ee8 b40e 0000 000e 0000 .5.QQ...........
^^ compression method
^^ ^^^^ ^^ date
^^ ^^^^ ^^ crc32
^^ ^^^^ ^^ compressed size (14)
^^ ^^^^
00000050: 0009 0000 0000 0000 0000 0000 0000 0000 ................
^^ uncompressed size (14)
^^ ^^ file name length (hello.txt) 9
^^ ^^ extra fields length (0)
<< headers
^^ ^^ file comment length (0)
^^ ^^ disk number start (0)
^^ ^^ internal file attributes (0)
^^ ^^ external file attributes (0)
^^ ^^^^
00000060: 0068 656c 6c6f 2e74 7874 504b 0506 0000 .hello.txtPK....
^^ offset of local header (0)
^^ ^^^^ ^^^^ ^^^^ ^^^^ file name (hello.txt)
^^^^ ^^^^ CENTRAL_DIRECTORY_END
^^^^ number of this disk
00000070: 0000 0100 0100 3500 0000 3500 0000 0000 ......5...5.....
^^^^ number of the disk with this central dir
^^^^ number of entries on this disk
^^^^ total number of entries
^^^^ ^^^^ length of central directory (53)
^^^^ ^^^^ central directory start (0x35)
^^^^ comment length
comment
// INVALID
============================================================
// VALID
00000000: 504b 0304 0a00 0000 0000 519b 5051 849e PK........Q.PQ..
^^^^ ^^^^ LOCAL_FILE_HEADER
^^^^ version 10
^^^^ bitFlag
^^^^ compression method (STORE)
^^^^ ^^^^ date
^^^^...
00000010: e8b4 0e00 0000 0e00 0000 0900 1c00 6865 ..............he
^^^^ crc32
^^^^ ^^^^ compressed size (14)
^^^^ ^^^^ uncompressed size (14)
^^^^ file name length (hello.txt) 9
^^^^ extra fields length (28)
^^^^
00000020: 6c6c 6f2e 7478 7455 5409 0003 5956 8a5f llo.txtUT...YV._
^^^^ ^^^^ ^^^^ ^^ file name
^^ ^^^^ ^^^^ ^^^^ ^^^^
00000030: 5b56 8a5f 7578 0b00 0104 f501 0000 0414 [V._ux..........
^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^
00000040: 0000 0048 656c 6c6f 2c20 576f 726c 6421 ...Hello, World!
^^^^ ^^ extra fields
^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^
00000050: 0a50 4b01 021e 030a 0000 0000 0051 9b50 .PK..........Q.P
^^ file content (14)
^^ ^^^^ ^^ CENTRAL_FILE_HEADER
^^ file version (30)
^^ file made by (3)
>> headers
^^ ^^ version 10
^^ ^^ bitFlag
^^ ^^ compression method
^^ ^^^^
00000060: 5184 9ee8 b40e 0000 000e 0000 0009 0018 Q...............
^^ date
^^ ^^^^ ^^ crc32
^^ ^^^^ ^^ compressed size
^^ ^^^^ ^^ uncompressed size
^^ ^^ file name length (9)
<< headers
^^
00000070: 0000 0000 0001 0000 00a4 8100 0000 0068 ...............h
^^^^ ^^ extra fields length (0x18 24)
^^ ^^ file comment length
^^ ^^ disk number start (1)
^^ ^^ internal file attribute (0)
^^ ^^ external file attribute (0xa481 0o122201???)
^^ ^^^^ ^^ offset of local header (0)
^^
00000080: 656c 6c6f 2e74 7874 5554 0500 0359 568a ello.txtUT...YV.
^^^^ ^^^^ ^^^^ ^^^^ file name
^^^^ ^^^^ ^^^^ ^^^^
00000090: 5f75 780b 0001 04f5 0100 0004 1400 0000 _ux.............
^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ extra fields (24)
000000a0: 504b 0506 0000 0000 0100 0100 4f00 0000 PK..........O...
^^^^ ^^^^ CENTRAL_DIRECTORY_END
^^^^ number of this disk (0)
^^^^ number of the disk with this central dir
^^^^ number of entires on the central dir on this disk (1)
^^^^ total number of entries in the central (1)
^^^^ ^^^^ central directory length (79)
000000b0: 5100 0000 0000 Q.....
^^^^ ^^^^ central directory start (0x51)
^^^^ comment length (0)
comment
00000000: 504b 0304 0a03 0000 0000 9c74 f13a e3e5 PK.........t.:..
^^^^ LOCAL_FILE_HEADER
00000010: 95b0 0c00 0000 0c00 0000 0900 0000 4865 ..............He
^^- fileName
00000020: 6c6c 6f2e 7478 7448 656c 6c6f 2057 6f72 llo.txtHello Wor
-^^ ^^- compressedBytes
00000030: 6c64 0a50 4b01 0214 030a 0300 0000 009c ld.PK...........
>> start of central directory
^^ ^^^^ ^^ CENTRAL_FILE_HEADER
00000040: 74f1 3ae3 e595 b00c 0000 000c 0000 0009 t.:.............
00000050: 0000 0000 0000 0000 0020 80a4 8100 0000 ......... ......
00000060: 0048 656c 6c6f 2e74 7874 504b 0506 0000 .Hello.txtPK....
<< end of central directory
^^^^ CENTRAL_DIRECTORY_END
^^^^ number of this disk
00000070: 0000 0100 0100 3700 0000 3300 0000 0000 ......7...3.....
^^^^ number of the disk with the start of the central dir
^^^^ number of entries in the central directory on this disk
^^^^ total number of entries in the central directory
^^^^ ^^^^ size of the central directory
^^^^ ^^^^ start of the central directory on the starting disk
^^^^ comment length
00000000: 504b 0304 0a03 0000 0000 9c6c f13a e3e5 PK.........l.:..
^^^^ LOCAL_FILE_HEADER
00000010: 95b0 0c00 0000 0c00 0000 0900 0000 4865 ..............He
00000020: 6c6c 6f2e 7478 7448 656c 6c6f 2057 6f72 llo.txtHello Wor
00000030: 6c64 0a50 4b03 040a 0300 0000 00b1 6cf1 ld.PK.........l.
^^ ^^ LOCAL_FILE_HEADAER
00000040: 3a00 0000 0000 0000 0000 0000 0007 0000 :...............
00000050: 0069 6d61 6765 732f 504b 0304 0a03 0000 .images/PK......
^^^^ LOCAL_FILE_HEADER
00000060: 0000 1567 ea3a 3c3f eb8a 2900 0000 2900 ...g.:<?..)...).
00000070: 0000 1000 0000 696d 6167 6573 2f73 6d69 ......images/smi
00000080: 6c65 2e67 6966 4749 4638 3761 0500 0500 le.gifGIF87a....
00000090: 8002 0000 0000 ffde 002c 0000 0000 0500 .........,......
000000a0: 0500 0002 088c 0f91 67ab 0a52 0100 3b50 ........g..R..;P
000000b0: 4b01 0214 030a 0300 0000 009c 6cf1 3ae3 K...........l.:.
^^ ^^ CENTRAL_FILE_HEADER
000000c0: e595 b00c 0000 000c 0000 0009 0000 0000 ................
000000d0: 0000 0000 0020 80a4 8100 0000 0048 656c ..... .......Hel
000000e0: 6c6f 2e74 7874 504b 0102 1403 0a03 0000 lo.txtPK........
^^^^ CENTRAL_FILE_HEADER
000000f0: 0000 b16c f13a 0000 0000 0000 0000 0000 ...l.:..........
00000100: 0000 0700 0000 0000 0000 0000 1080 ed41 ...............A
00000110: 3300 0000 696d 6167 6573 2f50 4b01 0214 3...images/PK...
^^ ^^ CENTRAL_FILE_HEADER
00000120: 030a 0300 0000 0015 67ea 3a3c 3feb 8a29 ........g.:<?..)
00000130: 0000 0029 0000 0010 0000 0000 0000 0000 ...)............
00000140: 0020 80a4 8158 0000 0069 6d61 6765 732f . ...X...images/
00000150: 736d 696c 652e 6769 6650 4b05 0600 0000 smile.gifPK.....
^^ ^^ CENTRAL_DIRECTORY_END
00000160: 0003 0003 00aa 0000 00af 0000 0000 00 ...............
00000000: 504b 0304 0a00 0800 0000 7683 2142 0000 PK........v.!B..
^^^^ LOCAL_FILE_HEADER
00000010: 0000 0c00 0000 0c00 0000 0900 1c00 4865 ..............He
00000020: 6c6c 6f2e 7478 7455 5409 0003 6f00 e350 llo.txtUT...o..P
00000030: 6f00 e350 7578 0b00 0104 e803 0000 04e8 o..Pux..........
00000040: 0300 0048 656c 6c6f 2057 6f72 6c64 0a50 ...Hello World.P
00000050: 4b07 08e3 e595 b00c 0000 000c 0000 0050 K..............P
^^ ^^ DATA_DESCRIPTOR
00000060: 4b01 021e 030a 0008 0000 0076 8321 42e3 K..........v.!B.
^^ ^^ CENTRAL_FILE_HEADER
00000070: e595 b00c 0000 000c 0000 0009 0018 0000 ................
00000080: 0000 0000 0000 00a4 8100 0000 0048 656c .............Hel
00000090: 6c6f 2e74 7874 5554 0500 036f 00e3 5075 lo.txtUT...o..Pu
000000a0: 780b 0001 04e8 0300 0004 e803 0000 504b x.............PK
000000b0: 0506 0000 0000 0100 0100 4f00 0000 5f00 ..........O..._.
^^^^ CENTRAL_DIRECTORY_END
000000c0: 0000 0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment