The call to pdb::msf::view will eventually lead to a call of read_exact with a length of 4096 which will fail since the file is not 4096 bytes long.
A quick fix to work around this, is back in pdb::msf::open_msf catch the error on the first call to view for std;:io::Error where ErrorKind is UnexpectedEof and turn that into pdb::Error::UnrecognizedFileFormat.
I have a change that does just that and will put it up for code review momentarily.
If a file is less than 4096 bytes in size and past into
pdb::PDB::open
, the result with be astd::io::Error
withErrorKind
UnexpectedEof
.An easy repro of this issue if to run the
pdb_symbols
example against a source fileI would expect to get the output
but instead I get the output
Digging into the code a little ways it appears this happens in
pdb::msf::open_msf
.https://github.com/willglynn/pdb/blob/ebaba994f28538ff8f04b9f8f5c20466621adaf2/src/msf/mod.rs#L386-L390
The call to
pdb::msf::view
will eventually lead to a call ofread_exact
with a length of 4096 which will fail since the file is not 4096 bytes long.A quick fix to work around this, is back in
pdb::msf::open_msf
catch the error on the first call toview
forstd;:io::Error
whereErrorKind
isUnexpectedEof
and turn that intopdb::Error::UnrecognizedFileFormat
.I have a change that does just that and will put it up for code review momentarily.