libgcrypt 1.7.0 segfault (libcrypt-gcrypt-perl)

Andreas Metzler ametzler at bebt.de
Thu Apr 21 18:53:24 CEST 2016


Hello,

libcrypt-gcrypt-perl triggers a segfault in libgcrypt 1.7.0. This does
not show with libgcrypt 1.6.

Quoting Niko Tyni ----------------------------------------------
The failure can be triggered with this:

 % perl -MCrypt::GCrypt -e '$c=Crypt::GCrypt->new(type=>"cipher",algorithm=>"aes");$c->start("encrypting"); $c->encrypt("a").$c->finish'

which gets a SIGSEGV in libgcrypt. Backtrace below.

Adding a $c->setkey('whatever') before calling encrypt() makes it go
away. The test isn't trying to do anything meaningful at that point,
it's just checking that it gets a warning when not calling $c->finish()
or something like that. Later tests of actual encrypting pass.

Is this something to be fixed on the libgcrypt side?

I guess I can come up with a C test case if needed, but maybe you
can cook up one easier? The perl side setkey() just seems to wrap
gcry_cipher_setkey().


  Core was generated by `debugperl -Iblib/lib -Iblib/arch -MCrypt::GCrypt -e $c=Crypt::GCrypt->new(type='.
  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x0000000000000000 in ?? ()
  (gdb) bt
  #0  0x0000000000000000 in ?? ()
  #1  0x00007f5a5bce89c5 in _gcry_aes_cbc_enc (context=0x280a8e0, iv=0x280a6d0 "", outbuf_arg=<optimized out>, 
      inbuf_arg=<optimized out>, nblocks=1, cbc_mac=0) at ../../cipher/rijndael.c:811
  #2  0x00007f5a5bcc6565 in _gcry_cipher_cbc_encrypt (c=0x280a660, 
      outbuf=outbuf at entry=0x27cf850 "a", '\017' <repeats 15 times>, outbuflen=outbuflen at entry=16, 
      inbuf=inbuf at entry=0x2840650 "a", '\017' <repeats 15 times>, inbuflen=<optimized out>)
      at ../../cipher/cipher-cbc.c:65
  #3  0x00007f5a5bcc5400 in cipher_encrypt (inbuflen=<optimized out>, 
      inbuf=0x2840650 "a", '\017' <repeats 15 times>, outbuflen=16, 
      outbuf=0x27cf850 "a", '\017' <repeats 15 times>, c=<optimized out>) at ../../cipher/cipher.c:826
  #4  _gcry_cipher_encrypt (h=<optimized out>, out=out at entry=0x27cf850, outsize=outsize at entry=16, 
      in=in at entry=0x2840650, inlen=<optimized out>, inlen at entry=16) at ../../cipher/cipher.c:913
  #5  0x00007f5a5bcba91e in gcry_cipher_encrypt (h=<optimized out>, out=0x27cf850, outsize=16, in=0x2840650, 
      inlen=16) at ../../src/visibility.c:828
  #6  0x00007f5a5bfc1a53 in XS_Crypt__GCrypt_finish (my_perl=0x2785010, cv=0x27d47f0) at GCrypt.xs:439
  #7  0x000000000050f456 in Perl_pp_entersub (my_perl=0x2785010) at pp_hot.c:3270
  #8  0x00000000004da689 in Perl_runops_debug (my_perl=0x2785010) at dump.c:2234
  #9  0x0000000000450e92 in S_run_body (oldscope=1, my_perl=0x2785010) at perl.c:2453
  #10 perl_run (my_perl=0x2785010) at perl.c:2376
  #11 0x000000000041d09b in main (argc=6, argv=0x7ffc0f9ebfe8, env=0x7ffc0f9ec020) at perlmain.c:116
----------------------------------------------------------------

cu Andreas
-- 
`What a good friend you are to him, Dr. Maturin. His other friends are
so grateful to you.'
`I sew his ears on from time to time, sure'



More information about the Gcrypt-devel mailing list