mpi: Explicitly limit the allowed input length for gcry_mpi_scan.
* mpi/mpicoder.c (MAX_EXTERN_SCAN_BYTES): New. (mpi_fromstr): Check against this limit. (_gcry_mpi_scan): Ditto. * tests/mpitests.c (test_maxsize): New. (main): Cal that test.
A too large buffer length may lead to an unsigned integer overflow on
systems where size_t > unsigned int (ie. 64 bit systems). The
computation of the required number of nlimbs may also be affected by
this. However this is not a real world case because any processing
which has allocated such a long buffer from an external source would
be prone to other DoS attacks: The required buffer length to exhibit
this overflow is at least 2^32 - 8 bytes.
- Signed-off-by: Werner Koch <wk@gnupg.org>