Hi Stephen,

Line 50 of gzip.cpp is probably the culprit:

void Gunzip::ProcessPrestreamHeader()

      ...

        if (buf[0] != MAGIC1 || buf[1] != MAGIC2) throw HeaderErr();

      ...

Can you breakpoint it and verify?

Jeff
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Walton, Jeffrey
> Sent: Wednesday, November 19, 2003 10:03 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Gzip & Gunzip code: Correct or rubbish
> 
> 
> Hi Stephen,
> 
> > #5  0x472d3a1e in __cxa_throw () from 
> > /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
> 
> Its probably blowing up on the ASSERT in the header check. 
> 
> Jeff
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Stephen torri
> > Sent: Tuesday, November 18, 2003 11:24 PM
> > To: cryptopp
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: Gzip & Gunzip code: Correct or rubbish
> > 
> > 
> > On Tue, 2003-11-18 at 19:32, Stephen torri wrote:
> > > On Tue, 2003-11-18 at 19:14, Scott Barnhart wrote:
> > > > Stephen,
> > > > 
> > > > Based on the code in test.cpp for GzipFile and 
> GunzipFile, I have
> > > > always used the following, and it should work for you:
> > > > 
> > > > // Gzip contents of plaintext into gzip_text;
> > > > StringSource(plaintext, true, new Gzip(new 
> > StringSink(gzip_text)));
> > > > 
> > > > // Ungzip contents of gzip_text into unzip_text;
> > > > StringSource(gzip_text, true, new Gunzip(new 
> > > > StringSink(unzip_text)));
> > > > 
> > 
> > I just decided to run the code as it stands. It core dumps on
> > the Gunzip line. Here is the backtrace:
> > 
> > #0  0x47355e81 in kill () from /lib/libc.so.6
> > #1  0x47355c25 in raise () from /lib/libc.so.6
> > #2  0x4735719b in abort () from /lib/libc.so.6
> > #3  0x472d3837 in __cxxabiv1::__terminate(void (*)()) ()
> >    from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
> > #4  0x472d3878 in std::terminate() ()
> >    from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
> > #5  0x472d3a1e in __cxa_throw ()
> >    from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5
> > #6  0x470e690f in CryptoPP::Inflator::OutputPast(unsigned, 
> unsigned) (
> >     this=0x8065450, length=10, distance=52) at
> > zinflate.cpp:261 #7  0x470e822e in 
> > CryptoPP::Inflator::DecodeBody() (this=0x8065450)
> >     at zinflate.cpp:558
> > #8  0x470e6fb0 in CryptoPP::Inflator::ProcessInput(bool)
> > (this=0x8065450,
> >     flush=true) at zinflate.cpp:345
> > #9  0x470e6c39 in CryptoPP::Inflator::Put2(unsigned char 
> > const*, unsigned, int, bool) (this=0x8065450, inString=0x0, 
> > length=0, messageEnd=-1, blocking=true)
> >     at zinflate.cpp:294
> > #10 0x46f6dd39 in 
> > CryptoPP::BufferedTransformation::ChannelPut2(std::string 
> > const&, unsigned char const*, unsigned, int, bool) (this=0x8065450,
> >     [EMAIL PROTECTED], begin=0x0, length=0, messageEnd=-1,
> > blocking=true)
> >     at cryptlib.cpp:189
> > #11 0x46f719ec in 
> > CryptoPP::BufferedTransformation::ChannelMessageEnd(std::strin
> > g const&, int, bool) (this=0x8065450, [EMAIL PROTECTED], 
> > propagation=-1,
> >     blocking=true) at cryptlib.h:881
> > #12 0x46f6e88c in 
> > CryptoPP::BufferedTransformation::TransferMessagesTo2(CryptoPP
> > ::BufferedTransformation&, unsigned&, std::string const&, bool) (
> >     this=0xb76b3204, [EMAIL PROTECTED], [EMAIL PROTECTED],
> >     [EMAIL PROTECTED], blocking=true) at cryptlib.cpp:354
> > #13 0x46f6ead0 in 
> > CryptoPP::BufferedTransformation::TransferAllTo2(CryptoPP::Buf
> > feredTransformation&, std::string const&, bool) 
> > (this=0xb76b3204, ---Type <return> to continue, or q <return> 
> > to quit---
> >     [EMAIL PROTECTED], [EMAIL PROTECTED], blocking=true) at 
> > cryptlib.cpp:395 #14 0x08058a35 in
> > CryptoPP::SourceTemplate<CryptoPP::StringStore>::PumpAll2(bool
> > ) () #15 0x0805948f in CryptoPP::Source::PumpAll() () #16 
> > 0x0805809a in CryptoPP::Source::SourceInitialize(bool,
> > CryptoPP::NameValuePairs const&) ()
> > #17 0x0805314e in 
> > CryptoPP::StringSource::StringSource<std::string>(std::string 
> > const&, bool, CryptoPP::BufferedTransformation*) () #18 
> > 0x080518e9 in AES_CFB_CipherEngine::encrypt(std::string) () 
> > #19 0x080527a0 in save(AES_CFB_CipherEngine&, std::string, 
> > std::string)
> > ()
> > #20 0x08052a26 in main ()
> > #21 0x473427a7 in __libc_start_main () from /lib/libc.so.6
> > 
> > Gcc: 3.2.3
> > Crypto++: 5.1
> > 
> > -----------------
> > strace
> > -----------------
> > bash-2.05b$ strace ./encryption_test
> > execve("./encryption_test", ["./encryption_test"], [/* 56 
> > vars */]) = 0 uname({sys="Linux", node="base.torri.org", ...}) = 0
> > brk(0)                                  = 0x8062660
> > mmap2(NULL, 4096, PROT_READ|PROT_WRITE, 
> MAP_PRIVATE|MAP_ANONYMOUS, -1,
> > 0) = 0x4082b000
> > open("/etc/ld.so.preload", O_RDONLY)    = 3
> > fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
> > close(3)                                = 0
> > open("cryptopp/.libs/i686/mmx/libcryptopp.so.0", O_RDONLY) = 
> > -1 ENOENT (No such file or directory) 
> > open("cryptopp/.libs/i686/libcryptopp.so.0", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/mmx/libcryptopp.so.0", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/libcryptopp.so.0", O_RDONLY) = 3 read(3, 
> > "[EMAIL PROTECTED],\000"...,
> > 1024) = 1024
> > fstat64(3, {st_mode=S_IFREG|0755, st_size=15678342, ...}) = 0 
> > getcwd("/home/storri/Documents/StephenTorri/cs502_project/src"
> > , 128) = 54 mmap2(NULL, 5857216, PROT_READ|PROT_EXEC, 
> > MAP_PRIVATE, 3, 0) = 0x4082c000 mprotect(0x40d4e000, 475072, 
> > PROT_NONE) = 0 mmap2(0x40d4e000, 466944, 
> > PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x521) = 
> > 0x40d4e000 mmap2(0x40dc0000, 8128, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40dc0000
> > close(3)                                = 0
> > open("cryptopp/.libs/i686/mmx/libstdc++.so.5", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/i686/libstdc++.so.5", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/mmx/libstdc++.so.5", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/libstdc++.so.5", O_RDONLY) = -1 ENOENT 
> > (No such file or directory)
> > open("/etc/ld.so.cache", O_RDONLY)      = 3
> > fstat64(3, {st_mode=S_IFREG|0644, st_size=99875, ...}) = 0 
> > mmap2(NULL, 99875, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40dc2000
> > close(3)                                = 0
> > open("/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libstdc++.so.5",
> > O_RDONLY) = 3
> > read(3, 
> "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\0\4\000"...,
> > 1024) = 1024
> > fstat64(3, {st_mode=S_IFREG|0755, st_size=1068068, ...}) = 0 
> > mmap2(NULL, 830140, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 
> > 0x40ddb000 mprotect(0x40e9c000, 39612, PROT_NONE)  = 0 
> > mmap2(0x40e9c000, 20480, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED, 3,
> > 0xc1) = 0x40e9c000
> > mmap2(0x40ea1000, 19132, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40ea1000
> > close(3)                                = 0
> > open("cryptopp/.libs/i686/mmx/libm.so.6", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/i686/libm.so.6", O_RDONLY) = -1 ENOENT 
> > (No such file or directory) 
> > open("cryptopp/.libs/mmx/libm.so.6", O_RDONLY) = -1 ENOENT 
> > (No such file or directory) open("cryptopp/.libs/libm.so.6", 
> > O_RDONLY) = -1 ENOENT (No such file or
> > directory)
> > open("/lib/libm.so.6", O_RDONLY)        = 3
> > read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\2405\0"...,
> > 1024) = 1024
> > fstat64(3, {st_mode=S_IFREG|0755, st_size=189625, ...}) = 0 
> > mmap2(NULL, 135616, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 
> > 0x40ea6000
> > mprotect(0x40ec7000, 448, PROT_NONE)    = 0
> > mmap2(0x40ec7000, 4096, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED, 3,
> > 0x21) = 0x40ec7000
> > close(3)                                = 0
> > open("cryptopp/.libs/i686/mmx/libgcc_s.so.1", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/i686/libgcc_s.so.1", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/mmx/libgcc_s.so.1", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/libgcc_s.so.1", O_RDONLY) = -1 ENOENT 
> > (No such file or directory) 
> > open("/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/libgcc_s.so.1",
> >  O_RDONLY) = 3 read(3, 
> > "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 \27\0\000"...,
> > 1024) = 1024
> > fstat64(3, {st_mode=S_IFREG|0644, st_size=153827, ...}) = 0 
> > mmap2(NULL, 35744, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 
> > 0x40ec8000
> > mprotect(0x40ed0000, 2976, PROT_NONE)   = 0
> > mmap2(0x40ed0000, 4096, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED, 3,
> > 0x7) = 0x40ed0000
> > close(3)                                = 0
> > open("cryptopp/.libs/i686/mmx/libc.so.6", O_RDONLY) = -1 
> > ENOENT (No such file or directory) 
> > open("cryptopp/.libs/i686/libc.so.6", O_RDONLY) = -1 ENOENT 
> > (No such file or directory) 
> > open("cryptopp/.libs/mmx/libc.so.6", O_RDONLY) = -1 ENOENT 
> > (No such file or directory) open("cryptopp/.libs/libc.so.6", 
> > O_RDONLY) = -1 ENOENT (No such file or
> > directory)
> > open("/lib/libc.so.6", O_RDONLY)        = 3
> > read(3, 
> "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`X\1\000"...,
> > 1024) = 1024
> > fstat64(3, {st_mode=S_IFREG|0755, st_size=1466302, ...}) = 0 
> > mmap2(NULL, 1231748, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) 
> > = 0x40ed1000 mprotect(0x40ff8000, 23428, PROT_NONE)  = 0 
> > mmap2(0x40ff8000, 16384, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED, 3,
> > 0x126) = 0x40ff8000
> > mmap2(0x40ffc000, 7044, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40ffc000
> > close(3)                                = 0
> > mmap2(NULL, 4096, PROT_READ|PROT_WRITE, 
> MAP_PRIVATE|MAP_ANONYMOUS, -1,
> > 0) = 0x40ffe000
> > munmap(0x40dc2000, 99875)               = 0
> > open("/dev/urandom", O_RDONLY)          = 3
> > read(3, 
> > "\3\7#\375\32\331\274o\352/\205w\6\222\375\221\267\342\310"...,
> > 32) = 32
> > close(3)                                = 0
> > brk(0)                                  = 0x8062660
> > brk(0x8063660)                          = 0x8063660
> > brk(0x8064000)                          = 0x8064000
> > open("Foo.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> > brk(0)                                  = 0x8064000
> > brk(0x8065000)                          = 0x8065000
> > brk(0)                                  = 0x8065000
> > brk(0x8066000)                          = 0x8066000
> > fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 1), 
> > ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, 
> > MAP_PRIVATE|MAP_ANONYMOUS, -1,
> > 0) = 0x40dc2000
> > write(1, "Plaintext char:  B  o  o     H  "..., 83Plaintext 
> > char:  B  o 
> > o     H  o  o     I     a  m     s  o     s  c  a  r  e  d
> > ) = 83
> > write(1, "Plaintext hex:  0x42  0x6f  0x6f"..., 148Plaintext 
> > hex:  0x42 
> > 0x6f  0x6f  0x20  0x48  0x6f  0x6f  0x20  0x49  0x20  0x61  
> > 0x6d  0x20 
> > 0x73  0x6f  0x20  0x73  0x63  0x61  0x72  0x65  0x64
> > ) = 148
> > brk(0)                                  = 0x8066000
> > brk(0x8067000)                          = 0x8067000
> > brk(0)                                  = 0x8067000
> > brk(0x8077000)                          = 0x8077000
> > brk(0)                                  = 0x8077000
> > brk(0x8087000)                          = 0x8087000
> > brk(0)                                  = 0x8087000
> > brk(0x8097000)                          = 0x8097000
> > brk(0)                                  = 0x8097000
> > brk(0x80a7000)                          = 0x80a7000
> > brk(0)                                  = 0x80a7000
> > brk(0x80a8000)                          = 0x80a8000
> > write(1, "Compressed text2:  0x1f  0xfffff"..., 
> 318Compressed text2: 
> > 0x1f  0xffffff8b  0x8  0  0  0  0  0  0  0  0x73  0xffffffca 
> > 0xffffffcf  0x57  0xfffffff0  0  0x62  0x4f  0xffffff85  0xffffffc4 
> > 0x5c  0xffffff85  0xffffffe2  0x7c  0xffffff85  0xffffffe2  
> > 0xffffffe4 
> > 0xffffffc4  0xffffffa2  0xffffffd4  0x14  0  0x42  0xffffff8f  0x7c 
> > 0xffffffd0  0x16  0  0  0
> > ) = 318
> > rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
> > getpid()                                = 15300
> > kill(15300, SIGABRT)                    = 0
> > --- SIGABRT (Aborted) @ 0 (0) ---
> > +++ killed by SIGABRT +++
> > 
> > The code file is attached. Curious.
> > 
> > Stephen
> > 
> 

Reply via email to