summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-09-10 10:28:03 +0200
committerWerner Koch <wk@gnupg.org>2002-09-10 10:28:03 +0200
commitd6a87e6b2898704d8131288f10083c37d5ec2fb4 (patch)
treeabc7e27b62084fbcb2630a336de3ba268160207d
parent* w32reg.c (read_w32_registry_string): Handle REG_EXPAND_SZ. (diff)
downloadgnupg2-d6a87e6b2898704d8131288f10083c37d5ec2fb4.tar.xz
gnupg2-d6a87e6b2898704d8131288f10083c37d5ec2fb4.zip
* mpicoder.c (mpi_set_buffer): Cast all left operands of a shift
to a larger type so that 16 bit CPUs don't suffer from an overflow. Suggested by TOGAWA Satoshi.
-rw-r--r--mpi/ChangeLog6
-rw-r--r--mpi/mpicoder.c14
2 files changed, 13 insertions, 7 deletions
diff --git a/mpi/ChangeLog b/mpi/ChangeLog
index e52518990..f20251ab4 100644
--- a/mpi/ChangeLog
+++ b/mpi/ChangeLog
@@ -1,3 +1,9 @@
+2002-09-03 Werner Koch <wk@gnupg.org>
+
+ * mpicoder.c (mpi_set_buffer): Cast all left operands of a shift
+ to a larger type so that 16 bit CPUs don't suffer from an
+ overflow. Suggested by TOGAWA Satoshi.
+
2002-08-24 David Shaw <dshaw@jabberwocky.com>
* longlong.h: Remove space between \ and newline. gcc is
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c
index 559facd89..1859b6331 100644
--- a/mpi/mpicoder.c
+++ b/mpi/mpicoder.c
@@ -405,10 +405,10 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
for(i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) {
#if BYTES_PER_MPI_LIMB == 4
- alimb = *p-- ;
- alimb |= *p-- << 8 ;
- alimb |= *p-- << 16 ;
- alimb |= *p-- << 24 ;
+ alimb = (mpi_limb_t)*p-- ;
+ alimb |= (mpi_limb_t)*p-- << 8 ;
+ alimb |= (mpi_limb_t)*p-- << 16 ;
+ alimb |= (mpi_limb_t)*p-- << 24 ;
#elif BYTES_PER_MPI_LIMB == 8
alimb = (mpi_limb_t)*p-- ;
alimb |= (mpi_limb_t)*p-- << 8 ;
@@ -426,9 +426,9 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
if( p >= buffer ) {
#if BYTES_PER_MPI_LIMB == 4
alimb = *p-- ;
- if( p >= buffer ) alimb |= *p-- << 8 ;
- if( p >= buffer ) alimb |= *p-- << 16 ;
- if( p >= buffer ) alimb |= *p-- << 24 ;
+ if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
+ if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
+ if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
#elif BYTES_PER_MPI_LIMB == 8
alimb = (mpi_limb_t)*p-- ;
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;