linux-IllusionX/lib/mpi
Nicolai Stange 462696fd0f lib/mpi: mpi_read_buffer(): fix buffer overflow
Currently, mpi_read_buffer() writes full limbs to the output buffer
and moves memory around to purge leading zero limbs afterwards.

However, with

  commit 9cbe21d8f8 ("lib/mpi: only require buffers as big as needed for
                        the integer")

the caller is only required to provide a buffer large enough to hold the
result without the leading zeros.

This might result in a buffer overflow for small MP numbers with leading
zeros.

Fix this by coping the result to its final destination within the output
buffer and not copying the leading zeros at all.

Fixes: 9cbe21d8f8 ("lib/mpi: only require buffers as big as needed for
                      the integer")
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2016-04-05 20:35:49 +08:00
..
generic_mpih-add1.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-lshift.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-mul1.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-mul2.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-mul3.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-rshift.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-sub1.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
longlong.h lib/mpi: avoid assembler warning 2016-02-28 03:26:34 +08:00
Makefile MPILIB: Reinstate mpi_cmp[_ui]() and export for RSA signature verification 2012-10-08 13:50:15 +10:30
mpi-bit.c MPILIB: Provide count_leading/trailing_zeros() based on arch functions 2012-10-08 13:50:11 +10:30
mpi-cmp.c MPILIB: Fix comparison of negative MPIs 2015-01-14 16:10:12 +00:00
mpi-inline.h lib/mpi: use "static inline" instead of "extern inline" 2016-02-28 03:26:34 +08:00
mpi-internal.h lib/mpi: use "static inline" instead of "extern inline" 2016-02-28 03:26:34 +08:00
mpi-pow.c MPILIB: Provide count_leading/trailing_zeros() based on arch functions 2012-10-08 13:50:11 +10:30
mpicoder.c lib/mpi: mpi_read_buffer(): fix buffer overflow 2016-04-05 20:35:49 +08:00
mpih-cmp.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
mpih-div.c Remove unused code from MPI library 2012-05-26 11:51:03 +10:00
mpih-mul.c Remove unused code from MPI library 2012-05-26 11:51:03 +10:00
mpiutil.c MPILIB: add mpi_read_buf() and mpi_get_size() helpers 2015-06-16 14:35:06 +08:00