[haiku-commits] Change in haiku[master]: HaikuDepot: Icon / Tarball Handling - Fix

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 15 Sep 2020 07:56:37 +0000

From Andrew Lindesay <apl@xxxxxxxxxxxxxx>:

Andrew Lindesay has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3219 ;)


Change subject: HaikuDepot: Icon / Tarball Handling - Fix
......................................................................

HaikuDepot: Icon / Tarball Handling - Fix

Resolves #16523
---
M src/apps/haikudepot/HaikuDepotConstants.h
M src/apps/haikudepot/tar/TarArchiveService.cpp
M src/apps/haikudepot/tar/TarArchiveService.h
3 files changed, 28 insertions(+), 14 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/19/3219/1

diff --git a/src/apps/haikudepot/HaikuDepotConstants.h 
b/src/apps/haikudepot/HaikuDepotConstants.h
index 9bb8a2b..ec701da 100644
--- a/src/apps/haikudepot/HaikuDepotConstants.h
+++ b/src/apps/haikudepot/HaikuDepotConstants.h
@@ -28,11 +28,11 @@
 };

 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
diff --git a/src/apps/haikudepot/tar/TarArchiveService.cpp 
b/src/apps/haikudepot/tar/TarArchiveService.cpp
index c0017b3..e77605f 100644
--- a/src/apps/haikudepot/tar/TarArchiveService.cpp
+++ b/src/apps/haikudepot/tar/TarArchiveService.cpp
@@ -116,13 +116,23 @@
 }


-/*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 @@
                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(
diff --git a/src/apps/haikudepot/tar/TarArchiveService.h 
b/src/apps/haikudepot/tar/TarArchiveService.h
index df0b92f..261dec7 100644
--- a/src/apps/haikudepot/tar/TarArchiveService.h
+++ b/src/apps/haikudepot/tar/TarArchiveService.h
@@ -38,8 +38,10 @@

        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);

--
To view, visit https://review.haiku-os.org/c/haiku/+/3219
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ied52904da51455fe164cda93daecde6dc3e051d4
Gerrit-Change-Number: 3219
Gerrit-PatchSet: 1
Gerrit-Owner: Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: HaikuDepot: Icon / Tarball Handling - Fix - Gerrit