This occurs on Linux Mint 17 with GnuPG 1.4.16.
I downloaded these files:
coreutils-8.23.tar.xz coreutils-8.23.tar.xz.sig
from
ftp://ftp.gnu.org/gnu/coreutils/
Intending to check the signature, I ran
gpg coreutils-8.23.tar.xz
rather than
gpg coreutils-8.23.tar.xz.sig
(that part was user error on my part). I received the following prompt:
gpg: coreutils-8.23.tar.xz: unknown suffix Enter new filename [...]:
where the "..." denotes a long string of non-printable characters.
I see two problems here (possibly this should be split into two
bug reports).
- GnuPG incorrectly detected what it thought was a file name in the coreutils-8.23.tar.xz file. It may not be possible to correct this completely, since any random file may contain what looks like GnuPG-specific metadata, but it would be nice if it were better at determining whether that metadata is valid or not.
- The suggested file name it printed included non-printing characters. *Some* of the non-printable characters were translated to hexadecimal, but others were passed through unmodified. The problem is in the make_printable_string() function in util/miscutil.c -- it assumes that bytes in the range 0x20..0x7f and 0xa1..0xff are printable, and others are not. This is valid for Latin-1, but not for UTF-8 (and I happen to be using the "en_US.UTF-8" locale).
I see that the newest GnuPG sources cloned from the Git repo
have changed the make_printable_string() function so it calls
sanitize_buffer(). I haven't tried this version, but a quick look
at the source indicates that it probably still has problems; it seems
to assume that all bytes in the ranges 0.20..0x7e and 0x80..0xff are
printable. The logic probably needs to be sensitive to the locale.
I can imagine that a carefully crafted input file that causes gpg to
print special characters that are meaningful to a terminal emulator
might even create a security problem, but I haven't spent any time
exploring that possibility.
Feel free to contact me if you need more information, but you should
be able to reproduce the problem on your end.