libarchive reads too many chars when extracting a file
Posted
by ojreadmore
on Stack Overflow
See other posts from Stack Overflow
or by ojreadmore
Published on 2010-05-21T14:58:09Z
Indexed on
2010/05/21
15:01 UTC
Read the original article
Hit count: 234
I've written a C program to extract files from a tar archive using libarchive.
I'd like to extract a file from this archive and print it to standard output. But I get extra characters. It's garbage, but it's from another file (possibly adjacent to it in the archive.) I expect output to end at </html>
.
Here is the code that reads this tar file.
libarchive 2.8.3 compiled on mac os X 10.6.3. gcc 4.2 x86_64
ls -l vendar-definition.html
gives me 1921
for the file size. And so shows tar tfv 0000.tar | grep vendar-definition.html
. So reports the C output that states the file size. To me this seems correct.
Two possibilities I can see for why my output is not as expected: 1.
I've made a beginner's mistake or 2.
multibyte characters in the archive files has something to do with it.
© Stack Overflow or respective owner