Page MenuHome GnuPG

Decrypting incomplete file hangs with 100% cpu use
Closed, ResolvedPublic

Description

When attempting to decrypt an incomplete encrypted file, gpg can hang with 100%
cpu use until interrupted. This happens when the encrypted file uses bzip2
compression and an RSA key. The expected behaviour is for gpg to report an
error and quit.

Steps to reproduce:

  1. Create some test data.

~$ head -c 16384 /dev/urandom >test.in

  1. Encrypt with a 2048-bit RSA test key, using bzip2 compression.

~$ gpg --encrypt --compress-algo bzip2 --recipient test@example <test.in >test.gpg

  1. Test normal operation.

~$ gpg --decrypt <test.gpg >test.out
gpg: encrypted with 2048-bit RSA key, ID B22C9B86, created 2009-03-11

"Test Key <test@example>"

~$ diff test.in test.out

  1. Stop encrypted stream after 8464 bytes - gpg reports error and quits as expected.

~$ head -c 8464 test.gpg | gpg --decrypt >test.out
gpg: block_filter 0x8121f90: read error (size=16383,a->size=16383)
gpg: encrypted_mdc packet with unknown version 255
gpg: block_filter: pending bytes!

  1. Stop encrypted stream after 8465 bytes - gpg consumes 100% cpu until interrupted

~$ head -c 8465 test.gpg | gpg --decrypt >test.out
gpg: encrypted with 2048-bit RSA key, ID B22C9B86, created 2009-03-11

"Test Key <test@example>"

gpg: block_filter: 1st length byte missing

gpg: Interrupt caught ... exiting

~$

Tested on Mac OS X 10.5 with gpg 2.0.10 and Xubuntu 7.04 with gpg 1.4.6.

Details

Version
2.0.10

Event Timeline

sjdrake added projects: gnupg, Bug Report.
sjdrake added a subscriber: sjdrake.

That might be a problem in libbz2 or in our glue code.

werner removed a project: Too Old.

Fixed in 1.4.10 - just released.

werner claimed this task.
werner removed a project: In Progress.

Fixed for 2.0.x in svn 5144.

These changes fix the problem as reported (retested gpg versions 1.4.10 and
2.0.13-svn5147). Thank you!

Sorry, didn't mean to change status with previous message, just confirming that
the issue I raised is resolved. Will try to set it back now.