diff options
author | David Shaw <[email protected]> | 2005-09-01 13:44:49 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2005-09-01 13:44:49 +0000 |
commit | 516ec53e024f085c892baca1405870311d69444f (patch) | |
tree | 93ce66cd11b2050ab8899becfeb77bfec2a321be | |
parent | * photoid.c (generate_photo_id): Enable readline completion and tilde (diff) | |
download | gnupg-516ec53e024f085c892baca1405870311d69444f.tar.gz gnupg-516ec53e024f085c892baca1405870311d69444f.zip |
* mpicoder.c (mpi_read): Fix minor bug in reading a zero-length MPI
(was failing unnecessarily).
Diffstat (limited to '')
-rw-r--r-- | mpi/ChangeLog | 5 | ||||
-rw-r--r-- | mpi/mpicoder.c | 14 |
2 files changed, 14 insertions, 5 deletions
diff --git a/mpi/ChangeLog b/mpi/ChangeLog index 775f437b4..a2af9f303 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -1,3 +1,8 @@ +2005-09-01 David Shaw <[email protected]> + + * mpicoder.c (mpi_read): Fix minor bug in reading a zero-length + MPI (was failing unnecessarily). + 2005-05-06 Werner Koch <[email protected]> * mpi-scan.c (mpi_putbyte, mpi_getbyte): Removed. Not used. diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index 46cfb5b1d..d5ce99971 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -80,16 +80,20 @@ mpi_read(IOBUF inp, unsigned *ret_nread, int secure) mpi_limb_t a; MPI val = MPI_NULL; + if (nread == nmax) + goto overflow; if( (c = iobuf_get(inp)) == -1 ) goto leave; - if (++nread >= nmax) - goto overflow; + nread++; nbits = c << 8; + + if (nread == nmax) + goto overflow; if( (c = iobuf_get(inp)) == -1 ) goto leave; - if (++nread >= nmax) - goto overflow; + nread++; nbits |= c; + if( nbits > MAX_EXTERN_MPI_BITS ) { log_error("mpi too large for this implementation (%u bits)\n", nbits); goto leave; @@ -112,7 +116,7 @@ mpi_read(IOBUF inp, unsigned *ret_nread, int secure) for( ; j > 0; j-- ) { a = 0; for(; i < BYTES_PER_MPI_LIMB; i++ ) { - if (nread >= nmax) { + if (nread == nmax) { #ifdef M_DEBUG mpi_debug_free (val); #else |