Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -369,11 +369,14 @@ - (instancetype)of_initWithIvar: (struct objc_ivar *)ivar { self = [super init]; @try { - _name = [[OFString alloc] initWithUTF8String: ivar->name]; + if (ivar->name != NULL) + _name = [[OFString alloc] + initWithUTF8String: ivar->name]; + _typeEncoding = ivar->type; _offset = ivar->offset; } @catch (id e) { [self release]; @throw e; @@ -388,12 +391,12 @@ @try { const char *name = ivar_getName(ivar); if (name != NULL) - _name = [[OFString alloc] initWithUTF8String: - ivar_getName(ivar)]; + _name = [[OFString alloc] initWithUTF8String: name]; + _typeEncoding = ivar_getTypeEncoding(ivar); _offset = ivar_getOffset(ivar); } @catch (id e) { [self release]; @throw e; Index: src/OFMutableTarArchiveEntry.h ================================================================== --- src/OFMutableTarArchiveEntry.h +++ src/OFMutableTarArchiveEntry.h @@ -32,21 +32,21 @@ @property (readwrite, copy, nonatomic) OFString *fileName; /*! * The mode of the entry. */ -@property (readwrite, nonatomic) uint16_t mode; +@property (readwrite, nonatomic) uint32_t mode; /*! * The UID of the owner. */ -@property (readwrite, nonatomic) uint16_t UID; +@property (readwrite, nonatomic) uint32_t UID; /*! * The GID of the group. */ -@property (readwrite, nonatomic) uint16_t GID; +@property (readwrite, nonatomic) uint32_t GID; /*! * The size of the file. */ @property (readwrite, nonatomic) uint64_t size; Index: src/OFMutableTarArchiveEntry.m ================================================================== --- src/OFMutableTarArchiveEntry.m +++ src/OFMutableTarArchiveEntry.m @@ -38,21 +38,21 @@ OFString *old = _fileName; _fileName = [fileName copy]; [old release]; } -- (void)setMode: (uint16_t)mode +- (void)setMode: (uint32_t)mode { _mode = mode; } -- (void)setUID: (uint16_t)UID +- (void)setUID: (uint32_t)UID { _UID = UID; } -- (void)setGID: (uint16_t)GID +- (void)setGID: (uint32_t)GID { _GID = GID; } - (void)setSize: (uint64_t)size Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -157,11 +157,11 @@ - (OFTarArchiveEntry *)nextEntry { OFTarArchiveEntry *entry; union { - char c[512]; + unsigned char c[512]; uint32_t u32[512 / sizeof(uint32_t)]; } buffer; bool empty = true; if (_mode != OF_TAR_ARCHIVE_MODE_READ) Index: src/OFTarArchiveEntry+Private.h ================================================================== --- src/OFTarArchiveEntry+Private.h +++ src/OFTarArchiveEntry+Private.h @@ -19,11 +19,11 @@ OF_ASSUME_NONNULL_BEGIN @class OFStream; @interface OFTarArchiveEntry () -- (instancetype)of_initWithHeader: (char [_Nonnull 512])header +- (instancetype)of_initWithHeader: (unsigned char [_Nonnull 512])header OF_METHOD_FAMILY(init); - (void)of_writeToStream: (OFStream *)stream; @end OF_ASSUME_NONNULL_END Index: src/OFTarArchiveEntry.h ================================================================== --- src/OFTarArchiveEntry.h +++ src/OFTarArchiveEntry.h @@ -48,13 +48,13 @@ * @brief A class which represents an entry of a tar archive. */ @interface OFTarArchiveEntry: OFObject { OFString *_fileName; - uint16_t _mode; + uint32_t _mode; uint64_t _size; - uint16_t _UID, _GID; + uint32_t _UID, _GID; OFDate *_modificationDate; of_tar_archive_entry_type_t _type; OFString *_Nullable _targetFileName; OFString *_Nullable _owner, *_Nullable _group; uint32_t _deviceMajor, _deviceMinor; @@ -66,21 +66,21 @@ @property (readonly, copy, nonatomic) OFString *fileName; /*! * The mode of the entry. */ -@property (readonly, nonatomic) uint16_t mode; +@property (readonly, nonatomic) uint32_t mode; /*! * The UID of the owner. */ -@property (readonly, nonatomic) uint16_t UID; +@property (readonly, nonatomic) uint32_t UID; /*! * The GID of the group. */ -@property (readonly, nonatomic) uint16_t GID; +@property (readonly, nonatomic) uint32_t GID; /*! * The size of the file. */ @property (readonly, nonatomic) uint64_t size; Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -24,17 +24,17 @@ #import "OFDate.h" #import "OFOutOfRangeException.h" static OFString * -stringFromBuffer(const char *buffer, size_t length) +stringFromBuffer(const unsigned char *buffer, size_t length) { for (size_t i = 0; i < length; i++) if (buffer[i] == '\0') length = i; - return [OFString stringWithUTF8String: buffer + return [OFString stringWithUTF8String: (const char *)buffer length: length]; } static void stringToBuffer(unsigned char *buffer, OFString *string, size_t length) @@ -49,13 +49,22 @@ for (size_t i = UTF8StringLength; i < length; i++) buffer[i] = '\0'; } static uintmax_t -octalValueFromBuffer(const char *buffer, size_t length, uintmax_t max) +octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max) { - uintmax_t value = [stringFromBuffer(buffer, length) octalValue]; + uintmax_t value; + + if (length == 0) + return 0; + + if (buffer[0] == 0x80) { + for (size_t i = 1; i < length; i++) + value = (value << 8) | buffer[i]; + } else + value = [stringFromBuffer(buffer, length) octalValue]; if (value > max) @throw [OFOutOfRangeException exception]; return value; @@ -70,25 +79,25 @@ - init { OF_INVALID_INIT_METHOD } -- (instancetype)of_initWithHeader: (char [512])header +- (instancetype)of_initWithHeader: (unsigned char [512])header { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFString *targetFileName; _fileName = [stringFromBuffer(header, 100) copy]; - _mode = (uint16_t)octalValueFromBuffer( - header + 100, 8, UINT16_MAX); - _UID = (uint16_t)octalValueFromBuffer( - header + 108, 8, UINT16_MAX); - _GID = (uint16_t)octalValueFromBuffer( - header + 116, 8, UINT16_MAX); + _mode = (uint32_t)octalValueFromBuffer( + header + 100, 8, UINT32_MAX); + _UID = (uint32_t)octalValueFromBuffer( + header + 108, 8, UINT32_MAX); + _GID = (uint32_t)octalValueFromBuffer( + header + 116, 8, UINT32_MAX); _size = (uint64_t)octalValueFromBuffer( header + 124, 12, UINT64_MAX); _modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: (of_time_interval_t)octalValueFromBuffer( @@ -190,21 +199,21 @@ - (OFString *)fileName { return _fileName; } -- (uint16_t)mode +- (uint32_t)mode { return _mode; } -- (uint16_t)UID +- (uint32_t)UID { return _UID; } -- (uint16_t)GID +- (uint32_t)GID { return _GID; } - (uint64_t)size