archivers/pbzip2: fix more issues after libc++ 19 patches

* Ensure the _bz2Header and _bz2HeaderZero members of BZ2StreamScanner
  do not contain an additional NUL byte.
* When comparing the magic header, compare from pHdr->begin() + hsp to
  pHdr->end(), making the code equivalent to what it was doing using
  std::basic_string::compare().

Submitted by:	paparodeo@proton.me
PR:		283655
MFH:		2025Q1
This commit is contained in:
Dimitry Andric
2025-01-18 21:26:02 +01:00
parent a21fa3ec07
commit 974d3ff054
@@ -1,6 +1,16 @@
--- BZ2StreamScanner.cpp.orig 2015-12-17 23:32:49 UTC
+++ BZ2StreamScanner.cpp
@@ -49,8 +49,8 @@ int BZ2StreamScanner::init( int hInFile, size_t inBuff
@@ -42,15 +42,15 @@ int BZ2StreamScanner::init( int hInFile, size_t inBuff
{
dispose();
- CharType bz2header[] = "BZh91AY&SY";
- // zero-terminated string
+ CharType bz2header[] =
+ { 'B', 'Z', 'h', '9', '1', 'A', 'Y', '&', 'S', 'Y' };
CharType bz2ZeroHeader[] =
- { 'B', 'Z', 'h', '9', 0x17, 0x72, 0x45, 0x38, 0x50, 0x90, 0 };
+ { 'B', 'Z', 'h', '9', 0x17, 0x72, 0x45, 0x38, 0x50, 0x90 };
_hInFile = hInFile;
_eof = false;
@@ -35,7 +45,7 @@
// compare the remaining part of magic header
- int cmpres = pHdr->compare( hsp, pHdr->size() - hsp,
- getInBuffSearchPtr() + hsp, pHdr->size() - hsp );
+ bool cmpres = equal( pHdr->begin() + hsp, pHdr->begin() + pHdr->size() - hsp,
+ bool cmpres = equal( pHdr->begin() + hsp, pHdr->end(),
+ getInBuffSearchPtr() + hsp );
+