mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
* mpicoder.c (do_get_buffer): Avoid zero length allocation.
Checked that all callers behave properly when NBYTES returns 0 as the length of the allocated buffer.
This commit is contained in:
parent
30c71fe67e
commit
42230d3783
@ -1,3 +1,9 @@
|
|||||||
|
2002-09-20 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* mpicoder.c (do_get_buffer): Avoid zero length allocation.
|
||||||
|
Checked that all callers behave properly when NBYTES returns 0 as
|
||||||
|
the length of the allocated buffer.
|
||||||
|
|
||||||
2002-09-10 Werner Koch <wk@gnupg.org>
|
2002-09-10 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* mpi-bit.c (mpi_normalize): Replaced the check for protected by
|
* mpi-bit.c (mpi_normalize): Replaced the check for protected by
|
||||||
|
@ -332,10 +332,13 @@ do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure )
|
|||||||
byte *p, *buffer;
|
byte *p, *buffer;
|
||||||
mpi_limb_t alimb;
|
mpi_limb_t alimb;
|
||||||
int i;
|
int i;
|
||||||
|
unsigned int n;
|
||||||
|
|
||||||
if( sign )
|
if( sign )
|
||||||
*sign = a->sign;
|
*sign = a->sign;
|
||||||
*nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
|
*nbytes = n = a->nlimbs * BYTES_PER_MPI_LIMB;
|
||||||
|
if (!n)
|
||||||
|
n++; /* avoid zero length allocation */
|
||||||
p = buffer = force_secure || mpi_is_secure(a) ? m_alloc_secure( *nbytes)
|
p = buffer = force_secure || mpi_is_secure(a) ? m_alloc_secure( *nbytes)
|
||||||
: m_alloc( *nbytes );
|
: m_alloc( *nbytes );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user