mpi: Fix a subtle bug setting spurious bits with in mpi_set_bit.
authorWerner Koch <wk@gnupg.org>
Fri, 9 May 2014 10:35:15 +0000 (12:35 +0200)
committerWerner Koch <wk@gnupg.org>
Fri, 9 May 2014 10:36:54 +0000 (12:36 +0200)
commit246b7aaae1ee459f440260bbc4ec2c01c5dc3362
tree6103218f81d4c3a42d1a83cbc86430806375ec22
parent42f097486eb1ab92f30fdab56865eec4af685def
mpi: Fix a subtle bug setting spurious bits with in mpi_set_bit.

* mpi/mpi-bit.c (_gcry_mpi_set_bit, _gcry_mpi_set_highbit): Clear
allocated but not used bits before resizing.
* tests/t-mpi-bits.c (set_bit_with_resize): New.
--

Reported-by: Martin Sewelies.
This bug is probably with us for many years.  Probably due to
different memory allocation patterns, it did first revealed itself
with 1.6.  It could be the reason for other heisenbugs.

Signed-off-by: Werner Koch <wk@gnupg.org>
mpi/mpi-bit.c
tests/t-mpi-bit.c