]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
return the size of the required buffer to hold the data
authorNikos Mavrogiannopoulos <nmav@crystal.(none)>
Fri, 11 Apr 2008 23:35:01 +0000 (02:35 +0300)
committerNikos Mavrogiannopoulos <nmav@crystal.(none)>
Fri, 11 Apr 2008 23:35:01 +0000 (02:35 +0300)
lib/opencdk/pubkey.c

index 78ff8b0b193de218499135705787eae8fde3b733..acb4117804f09021d529744f51825ba6c4f15f5e 100644 (file)
@@ -621,9 +621,12 @@ mpi_to_buffer (gcry_mpi_t a, byte *buf, size_t buflen,
   nbits = gcry_mpi_get_nbits (a);
   if (r_nbits)
     *r_nbits = nbits;
+
+  if (r_nwritten)
+    *r_nwritten = (nbits+7)/8+2;
+
   if ((nbits+7)/8+2 > buflen)
     return CDK_Too_Short;
-  *r_nwritten = (nbits+7)/8+2;
 
   if (gcry_mpi_print (GCRYMPI_FMT_PGP, buf, buflen, r_nwritten, a))
     return CDK_Wrong_Format;