Index: src/OFZooArchiveEntry.m ================================================================== --- src/OFZooArchiveEntry.m +++ src/OFZooArchiveEntry.m @@ -346,16 +346,16 @@ commentLength = [_fileComment cStringLengthWithEncoding: encoding]; if (commentLength > UINT16_MAX) @throw [OFOutOfRangeException exception]; fileNameLength = [_fileName cStringLengthWithEncoding: encoding]; - if (fileNameLength > UINT8_MAX) + if (fileNameLength > UINT8_MAX - 1) @throw [OFOutOfRangeException exception]; directoryNameLength = [_directoryName cStringLengthWithEncoding: encoding]; - if (directoryNameLength > UINT8_MAX) + if (directoryNameLength > UINT8_MAX - 1) @throw [OFOutOfRangeException exception]; [data addItems: "\xDC\xA7\xC4\xFD" count: 4]; /* Header type */ [data addItem: "\x02"]; @@ -411,10 +411,16 @@ * CRC16 is filled when writing the next header, as the CRC needs to * include the next header offset. */ [data increaseCountBy: 2]; + /* Include \0 */ + if (fileNameLength > 0) + fileNameLength++; + if (directoryNameLength > 0) + directoryNameLength++; + tmp8 = (uint8_t)fileNameLength; [data addItem: &tmp8]; tmp8 = (uint8_t)directoryNameLength; [data addItem: &tmp8];