diff options
author | Werner Koch <[email protected]> | 2004-12-20 10:05:20 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-12-20 10:05:20 +0000 |
commit | 9e3526f236a94423830b75e59db40d20ac69b856 (patch) | |
tree | 5d8cd39ecce834747ea5fc7295eb2a8e1a21a48e /mpi/mpicoder.c | |
parent | (handle_iconv_error): Turn diagnostics into warnings (diff) | |
download | gnupg-9e3526f236a94423830b75e59db40d20ac69b856.tar.gz gnupg-9e3526f236a94423830b75e59db40d20ac69b856.zip |
* seckey-cert.c (do_check): Handle case when checksum was okay but
passphrase still wrong. Roman Pavlik found such a case.
* mpicoder.c (mpi_read_from_buffer): Don't abort in case of an
invalid MPI but print a message and return NULL. Use log_info and
not log_error.
Diffstat (limited to 'mpi/mpicoder.c')
-rw-r--r-- | mpi/mpicoder.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index 0005f21a8..4d4e45553 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -125,7 +125,7 @@ mpi_read(IOBUF inp, unsigned *ret_nread, int secure) MPI -mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure) +mpi_read_from_buffer(byte *buffer, unsigned int *ret_nread, int secure) { int i, j; unsigned nbits, nbytes, nlimbs, nread=0; @@ -136,7 +136,7 @@ mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure) goto leave; nbits = buffer[0] << 8 | buffer[1]; if( nbits > MAX_EXTERN_MPI_BITS ) { - log_error("mpi too large (%u bits)\n", nbits); + log_info ("mpi too large (%u bits)\n", nbits); goto leave; } buffer += 2; @@ -154,10 +154,19 @@ mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure) for( ; j > 0; j-- ) { a = 0; for(; i < BYTES_PER_MPI_LIMB; i++ ) { - if( ++nread > *ret_nread ) - log_bug("mpi larger than buffer\n"); - a <<= 8; - a |= *buffer++; + if( ++nread > *ret_nread ) { + /* This (as well as the above error condition) may + happen if we use this function to parse a decrypted + MPI which didn't turn out to be a real MPI - possible + because the supplied key was wrong but the OpenPGP + checksum didn't caught it. */ + log_info ("mpi larger than buffer\n"); + mpi_free (val); + val = MPI_NULL; + goto leave; + } + a <<= 8; + a |= *buffer++; } i = 0; val->d[j-1] = a; |