rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
634 stars 116 forks source link

[Bug]: Reading binary stream to determine file format code reading data exception #133

Open psvajaz opened 1 year ago

psvajaz commented 1 year ago

bit7z version

4.0.x RC

Compilation options

BIT7Z_AUTO_FORMAT, BIT7Z_AUTO_PREFIX_LONG_PATHS

7-zip version

v22.01

7-zip shared library used

7z.dll / 7z.so

Compilers

MSVC

Compiler versions

MSVC2017

Architecture

x86

Operating system

Windows

Operating system versions

Windows 11

Bug description

bitinputarchive.cpp -> openArchive -> Streamfile_stream = bit7z::make_com< CFileInStream, IInStream >( arc_path ); bitexception.cpp -> CFileInStream > mFileStream.rdbuf()->pubsetbuf( mBuffer.data(), buffer_size ); Loading file binary to mBuffer is all 0x00.

mFileStream.rdbuf()->pubsetbuf( mBuffer.data(), buffer_size ); modify to mFileStream.read(mBuffer.data(), buffer_size); is ok.

but return to readSignature is all 0x00

Steps to reproduce

No response

Expected behavior

No response

Relevant compilation output

No response

Code of Conduct

rikyoz commented 1 year ago

Hi!

Sorry, could you give more details on the issue? What are you trying to achieve? Thanks!

mFileStream.rdbuf()->pubsetbuf( mBuffer.data(), buffer_size ); modify to mFileStream.read(mBuffer.data(), buffer_size); is ok. but return to readSignature is all 0x00

The code mFileStream.rdbuf()->pubsetbuf( mBuffer.data(), buffer_size ); in CFileInStream's constructor is correct. In the constructor, we are not trying to read the file; rather, we are setting the buffer that will be used for the subsequent read operations performed by 7-zip.