summaryrefslogtreecommitdiff
path: root/mpi/mpicoder.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-04-02 08:40:21 +0000
committerWerner Koch <wk@gnupg.org>2003-04-02 08:40:21 +0000
commite3ec9ea7b8284b540795d6e5e02d4676b27dbb42 (patch)
tree18827c138ea37aaf6171448bb1e5e442c4a1fedb /mpi/mpicoder.c
parentbb01dfbe3cd522c4831e95e2cd8f93adc63be400 (diff)
downloadlibgcrypt-e3ec9ea7b8284b540795d6e5e02d4676b27dbb42.tar.gz
* mpicoder.c (gcry_mpi_print): Fixed testing against possible
uninitialized LEN. Valgrinded by Nikos Mavroyanopoulos.
Diffstat (limited to 'mpi/mpicoder.c')
-rw-r--r--mpi/mpicoder.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c
index 3051b410..7e2c9f21 100644
--- a/mpi/mpicoder.c
+++ b/mpi/mpicoder.c
@@ -479,7 +479,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes,
extra=1;
}
- if( n > len && buffer ) {
+ if (buffer && n > len) {
gcry_free(tmp);
return GCRYERR_TOO_SHORT; /* the provided buffer is too short */
}
@@ -500,7 +500,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes,
/* we ignore the sign for this format */
/* FIXME: for performance reasons we should put this into
* mpi_aprint becuase we can then use the buffer directly */
- if( n > len && buffer )
+ if (buffer && n > len)
return GCRYERR_TOO_SHORT; /* the provided buffer is too short */
if( buffer ) {
char *tmp;
@@ -517,7 +517,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes,
if( a->sign )
return GCRYERR_INV_ARG; /* pgp format can only handle unsigned */
- if( n+2 > len && buffer )
+ if (buffer && n+2 > len)
return GCRYERR_TOO_SHORT; /* the provided buffer is too short */
if( buffer ) {
char *tmp;
@@ -546,7 +546,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes,
extra=1;
}
- if( n+4 > len && buffer ) {
+ if (buffer && n+4 > len) {
gcry_free(tmp);
return GCRYERR_TOO_SHORT; /* the provided buffer is too short */
}
@@ -575,7 +575,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes,
if( !n || (*tmp & 0x80) )
extra=2;
- if( 2*n + extra + !!a->sign + 1 > len && buffer ) {
+ if(buffer && 2*n + extra + !!a->sign + 1 > len) {
gcry_free(tmp);
return GCRYERR_TOO_SHORT; /* the provided buffer is too short */
}