From 1559102fe7248296e5bb257d63123c0808d01d9d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 20 May 2013 14:25:31 +0200 Subject: [PATCH] ReaderImplBase: Fix strings subsection validity check A strings section with 0 strings is still 1 byte long. Also improve the error output in the error case. --- src/kits/package/hpkg/ReaderImplBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kits/package/hpkg/ReaderImplBase.cpp b/src/kits/package/hpkg/ReaderImplBase.cpp index 37e23d69b8..ad83419906 100644 --- a/src/kits/package/hpkg/ReaderImplBase.cpp +++ b/src/kits/package/hpkg/ReaderImplBase.cpp @@ -617,11 +617,11 @@ ReaderImplBase::InitSection(PackageFileSection& section, uint64 endOffset, } // check strings subsection size/count - if ((stringsLength == 0) != (stringsCount == 0) || stringsLength > length) { + if ((stringsLength <= 1) != (stringsCount == 0) || stringsLength > length) { ErrorOutput()->PrintError("Error: strings subsection description of %s " "file %s section is invalid (%" B_PRIu64 " strings, length: %" - B_PRIu64 ")\n", - fFileType, section.name, length, stringsCount, stringsLength); + B_PRIu64 ", section length: %" B_PRIu64 ")\n", + fFileType, section.name, stringsCount, stringsLength, length); return B_BAD_DATA; }