gpg-interface: do not scan past the end of buffer