HaikuDepot: Icon / Tarball Handling - Fix

Resolves #16523

Change-Id: Ied52904da51455fe164cda93daecde6dc3e051d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3219
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Andrew Lindesay
2020-09-15 08:22:47 +00:00
parent eb7ac342a0
commit 963ebbca4f
3 changed files with 28 additions and 14 deletions
+5 -5
View File
@@ -28,11 +28,11 @@ enum {
};
enum BitmapSize {
BITMAP_SIZE_16 = 1,
BITMAP_SIZE_22 = 2,
BITMAP_SIZE_32 = 3,
BITMAP_SIZE_64 = 4,
BITMAP_SIZE_ANY = 5
BITMAP_SIZE_16 = 0,
BITMAP_SIZE_22 = 1,
BITMAP_SIZE_32 = 2,
BITMAP_SIZE_64 = 3,
BITMAP_SIZE_ANY = 4
};
// when somebody rates a package, there is a numerical
+19 -7
View File
@@ -116,13 +116,23 @@ TarArchiveService::_ReadHeaderFileType(unsigned char data) {
}
/*const*/ const BString
TarArchiveService::_ReadHeaderString(const uint8 *data, size_t dataLength)
/*static*/ int32
TarArchiveService::_ReadHeaderStringLength(const uint8* data,
size_t maxStringLength)
{
uint32 actualLength = 0;
while (actualLength < dataLength && 0 != data[actualLength])
int32 actualLength = 0;
while (actualLength < (int32) maxStringLength && data[actualLength] != 0)
actualLength++;
return BString((const char *) data, actualLength);
return actualLength;
}
void
TarArchiveService::_ReadHeaderString(const uint8 *data, size_t maxStringLength,
BString& result)
{
result.SetTo((const char *) data,
_ReadHeaderStringLength(data, maxStringLength));
}
@@ -198,8 +208,10 @@ TarArchiveService::_ReadHeader(const uint8* block, TarArchiveHeader& header)
return B_BAD_DATA;
}
header.SetFileName(
_ReadHeaderString(&block[OFFSET_FILENAME], LENGTH_FILENAME));
BString fileName;
_ReadHeaderString(&block[OFFSET_FILENAME], LENGTH_FILENAME, fileName);
header.SetFileName(fileName);
header.SetLength(
_ReadHeaderNumeric(&block[OFFSET_LENGTH], LENGTH_LENGTH));
header.SetFileType(
+4 -2
View File
@@ -38,8 +38,10 @@ private:
static status_t _ReadHeader(const uint8* data,
TarArchiveHeader& header);
static const BString _ReadHeaderString(const uint8* data,
size_t dataLength);
static int32 _ReadHeaderStringLength(const uint8* data,
size_t maxStringLength);
static void _ReadHeaderString(const uint8* data,
size_t dataLength, BString& result);
static uint32 _ReadHeaderNumeric(const uint8* data,
size_t dataLength);
static tar_file_type _ReadHeaderFileType(uint8 data);