pombreda / libarchive

Automatically exported from code.google.com/p/libarchive
Other
0 stars 0 forks source link

following Issue 385: Truncated tar archive issue with the archive_read_data method #386

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Try to read a zip file that is attached : test.zip. This file can be opened 
with 7-zip for instance

Here is my code :

//Begin

      //Test to unzip direclty
      std::string aFileTest= aRootLocalFileName + "test.zip";
      TRC_DBG(APP, "TEST_CC aFileTest is:" << aFileTest);

      //Debut
      struct archive *aArchivetest ;
      aArchivetest= archive_read_new();
      //archive_read_support_compression_all(aArchivetest);
      archive_read_support_format_all(aArchivetest);

      if (archive_read_open_filename(aArchivetest, aFileTest.c_str(), 8192) != ARCHIVE_OK) {
       TRC_DBG(APP, "archive_read_open_filename KO");
       TRC_DBG(APP, "archive_errno is : " << archive_errno(aArchivetest));
       TRC_DBG(APP, "archive_string is : " << archive_error_string(aArchivetest));

      }
      else
      {
        TRC_DBG(APP, "archive_read_open_filename OK");
      }

      struct archive_entry* aArcEntry;

      if (ARCHIVE_OK==archive_read_next_header(aArchivetest, &aArcEntry))
      {

          TRC_DBG(APP,"archive_entry_pathname : " << archive_entry_pathname(aArcEntry));

          long int  aUnzipSize= 0;
          unsigned int aUnzipBlobSize=3000;  //Max value
          char aUnzipBlob[3000];

          TRC_DBG(APP, "content of the archive is : " << aArchivetest);
          aUnzipSize= archive_read_data(aArchivetest, aUnzipBlob, aUnzipBlobSize);
          if (aUnzipSize<0)
          {
            TRC_DBG(APP, "archive_errno is : " << archive_errno(aArchivetest));
            TRC_DBG(APP, "archive_string is : " << archive_error_string(aArchivetest));
          }
          else
          {
            std::string aUzippedStr(aUnzipBlob,aUnzipSize);
            TRC_DBG(APP, "unzipped content is : " << aUzippedStr);
          }

     }
      else
      {
        TRC_DBG(APP, "archive_errno is : " << archive_errno(aArchivetest));
       TRC_DBG(APP, "archive_string is : " << archive_error_string(aArchivetest));
      }

//End

Result with the test.zip file that is attached :

archive_read_open_filename OK
archive_entry_pathname : PK^C^D^T
archive_errno is : -1
archive_string is : Truncated tar archive

Now if I take the test.zip file, I unzip it (Linux unzip command), I can see it 
contains : EventProperties file
Then I zip it into a new test.zip file, I play again the code and I can see as 
a result :

archive_read_open_filename OK
archive_entry_pathname : EventProperties
content of the archive is : 0x7f0668105f20
unzipped content is : 
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPFBheWxvYWQ+CjxQcm9ncmFtTmFt
ZT5hY2VpbnYxYjwvUHJvZ3JhbU5hbWU+CjxUZW1wbGF0ZU5hbWU+Y2MvY3VzdG9tX3RvdnphL3VrL3Jw
dC9hY2UvYWNlaW52MWIucnB0PC9UZW1wbGF0ZU5hbWU+CjxEb2NEYXRlPjIwMTQtMDgtMjI8L0RvY0Rh
dGU+CjxUeXBlPlNQPC9UeXBlPgo8TGFuZ0NkZT5VSzwvTGFuZ0NkZT4KPFByaW50ZXJOYW1lPjwvUHJp
bnRlck5hbWU+CjxCYXRjaFByb2ZpbGU+SU5WT0lDRTwvQmF0Y2hQcm9maWxlPgo8T3V0cHV0UXVldWU+
REVGQVVMVDwvT3V0cHV0UXVldWU+CjxPdXRwdXRDb3BpZXM+MTwvT3V0cHV0Q29waWVzPgo8UHJldmll
d0NoZWNrQm94Pm5vdCBzZWxlY3RlZDwvUHJldmlld0NoZWNrQm94Pgo8QmF0Y2hDaGVja0JveD5zZWxl
Y3RlZDwvQmF0Y2hDaGVja0JveD4KPEZpbmFsUHJpbnRNZXRob2Q+YmF0Y2g8L0ZpbmFsUHJpbnRNZXRo
b2Q+CjxQREZOYW1lIFJlc3VsdD0iMDc2X2luXzM1MDgxNzhfZm91cmllZG9ub3Zhbl8wNzA5MjAxNF8y
MjE0OTQyNi5wZGYiLz4KPFJldHVybmVkRmlsZXM+CjxGaWxlIFJlc3VsdD0iMDc2X2luXzM1MDgxNzhf
Zm91cmllZG9ub3Zhbl8wNzA5MjAxNF8yMjE0OTQyNi5wZGYiLz4KPC9SZXR1cm5lZEZpbGVzPgo8L1Bh
eWxvYWQ+
2

What version are you using?
3.1.2

On what operating system?
Linux

Original issue reported on code.google.com by christop...@gmail.com on 19 Nov 2014 at 1:36

GoogleCodeExporter commented 9 years ago

Original comment by christop...@gmail.com on 20 Nov 2014 at 8:05

Attachments:

GoogleCodeExporter commented 9 years ago
I tried your test.zip with github master and it seems to work fine.

Could you please try with that version and let us know?

Original comment by kientzle@gmail.com on 20 Nov 2014 at 3:12

GoogleCodeExporter commented 9 years ago
I took from http://www.libarchive.org/ the Stable release: 
libarchive-3.1.2.tar.gz
could you please show me which value do you have for :archive_entry_pathname 
with my test.zip file ? 

Original comment by christop...@gmail.com on 20 Nov 2014 at 3:54

GoogleCodeExporter commented 9 years ago
by the way I tried to use the zip file here :
https://github.com/libarchive/libarchive

but it didn't compile :
cc1: warnings being treated as errors
libarchive/archive_write_set_format_warc.c: In function 'xstrftime':
libarchive/archive_write_set_format_warc.c:328: error: declaration of 'time' 
shadows a global declaration
/usr/include/time.h:186: error: shadowed declaration is here
make[1]: *** [libarchive/archive_write_set_format_warc.lo] Error 1
make[1]: Leaving directory 
`/remote/users/ccarrere/dev/test/libarchive-master/libarchive-master'
make: *** [all] Error 2

Original comment by christop...@gmail.com on 21 Nov 2014 at 8:04

GoogleCodeExporter commented 9 years ago
Morever :
hg clone https://github.com/libarchive/libarchive.git fails :
abort: HTTP Error 406: Not Acceptable

Original comment by christop...@gmail.com on 21 Nov 2014 at 10:27

GoogleCodeExporter commented 9 years ago
Finally I used GitHub but I have a other problem :

libarchive% /bin/sh build/autogen.sh
+ aclocal -I build/autoconf
configure.ac:108: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in 
body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
/usr/share/aclocal/libtool.m4:1022: _LT_SYS_MODULE_PATH_AIX is expanded from...
/usr/share/aclocal/libtool.m4:4158: _LT_LINKER_SHLIBS is expanded from...
/usr/share/aclocal/libtool.m4:5233: _LT_LANG_C_CONFIG is expanded from...
/usr/share/aclocal/libtool.m4:138: _LT_SETUP is expanded from...
/usr/share/aclocal/libtool.m4:67: LT_INIT is expanded from...
/usr/share/aclocal/libtool.m4:102: AC_PROG_LIBTOOL is expanded from...
configure.ac:108: the top level
configure.ac:108: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in 
body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
/usr/share/aclocal/libtool.m4:4158: _LT_LINKER_SHLIBS is expanded from...
/usr/share/aclocal/libtool.m4:5233: _LT_LANG_C_CONFIG is expanded from...
/usr/share/aclocal/libtool.m4:138: _LT_SETUP is expanded from...
/usr/share/aclocal/libtool.m4:67: LT_INIT is expanded from...
/usr/share/aclocal/libtool.m4:102: AC_PROG_LIBTOOL is expanded from...
configure.ac:108: the top level
+ case `uname` in
++ uname
+ libtoolize --automake -c
.ibtoolize: AC_CONFIG_MACRO_DIR([build/autoconf]) conflicts with 
ACLOCAL_AMFLAGS=-I build/autoconf

Original comment by christop...@gmail.com on 21 Nov 2014 at 10:57

GoogleCodeExporter commented 9 years ago
no news to help me to solve my last issue to play 
/bin/sh build/autogen.sh
with no errors?
I tried it to : 2.6.32.23-0.3-default GNU/Linux

Original comment by christop...@gmail.com on 24 Nov 2014 at 4:38

GoogleCodeExporter commented 9 years ago
Please try using cmake; it tends to work a little more reliably.

Original comment by t...@kientzle.com on 24 Nov 2014 at 7:12

GoogleCodeExporter commented 9 years ago
Thanks for your advice, I will try it to compile.
but first I should run /bin/sh build/autogen.sh

Do you think it will solve this issue?

Original comment by christop...@gmail.com on 25 Nov 2014 at 9:05

GoogleCodeExporter commented 9 years ago
I am not able to compile or to make a lib from the master branch. Is it 
possible to have a zip file of the last version to test if it solves my initial 
issue?

Original comment by christop...@gmail.com on 26 Nov 2014 at 5:27