Blame SOURCES/libgcrypt-1.6.1-mpicoder-gccopt.patch

66e42d
diff -up libgcrypt-1.6.1/mpi/mpicoder.c.gccopt libgcrypt-1.6.1/mpi/mpicoder.c
66e42d
--- libgcrypt-1.6.1/mpi/mpicoder.c.gccopt	2014-02-28 15:37:53.983139821 +0100
66e42d
+++ libgcrypt-1.6.1/mpi/mpicoder.c	2014-02-28 15:47:35.312576387 +0100
66e42d
@@ -627,16 +627,16 @@ _gcry_mpi_print (enum gcry_mpi_format fo
66e42d
           extra = 1;
66e42d
 	}
66e42d
 
66e42d
-      if (buffer && n > len)
66e42d
-        {
66e42d
-          /* The provided buffer is too short. */
66e42d
-          xfree (tmp);
66e42d
-          return GPG_ERR_TOO_SHORT;
66e42d
-	}
66e42d
       if (buffer)
66e42d
         {
66e42d
           unsigned char *s = buffer;
66e42d
 
66e42d
+          if (n > len)
66e42d
+            {
66e42d
+              /* The provided buffer is too short. */
66e42d
+              xfree (tmp);
66e42d
+              return GPG_ERR_TOO_SHORT;
66e42d
+            }
66e42d
           if (extra == 1)
66e42d
             *s++ = 0;
66e42d
           else if (extra)
66e42d
@@ -654,13 +654,12 @@ _gcry_mpi_print (enum gcry_mpi_format fo
66e42d
       /* Note:  We ignore the sign for this format.  */
66e42d
       /* FIXME: for performance reasons we should put this into
66e42d
 	 mpi_aprint because we can then use the buffer directly.  */
66e42d
-
66e42d
-      if (buffer && n > len)
66e42d
-        return GPG_ERR_TOO_SHORT;
66e42d
       if (buffer)
66e42d
         {
66e42d
           unsigned char *tmp;
66e42d
 
66e42d
+          if (n > len)
66e42d
+            return GPG_ERR_TOO_SHORT;
66e42d
           tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
66e42d
           if (!tmp)
66e42d
             return gpg_err_code_from_syserror ();
66e42d
@@ -678,14 +677,14 @@ _gcry_mpi_print (enum gcry_mpi_format fo
66e42d
       if (negative)
66e42d
         return GPG_ERR_INV_ARG;
66e42d
 
66e42d
-      if (buffer && n+2 > len)
66e42d
-        return GPG_ERR_TOO_SHORT;
66e42d
-
66e42d
       if (buffer)
66e42d
         {
66e42d
           unsigned char *tmp;
66e42d
           unsigned char *s = buffer;
66e42d
 
66e42d
+          if (n+2 > len)
66e42d
+            return GPG_ERR_TOO_SHORT;
66e42d
+
66e42d
           s[0] = nbits >> 8;
66e42d
           s[1] = nbits;
66e42d
 
66e42d
@@ -724,16 +723,16 @@ _gcry_mpi_print (enum gcry_mpi_format fo
66e42d
           extra=1;
66e42d
 	}
66e42d
 
66e42d
-      if (buffer && n+4 > len)
66e42d
-        {
66e42d
-          xfree(tmp);
66e42d
-          return GPG_ERR_TOO_SHORT;
66e42d
-	}
66e42d
-
66e42d
       if (buffer)
66e42d
         {
66e42d
           unsigned char *s = buffer;
66e42d
 
66e42d
+          if (n+4 > len)
66e42d
+            {
66e42d
+              xfree(tmp);
66e42d
+              return GPG_ERR_TOO_SHORT;
66e42d
+            }
66e42d
+
66e42d
           *s++ = n >> 24;
66e42d
           *s++ = n >> 16;
66e42d
           *s++ = n >> 8;
66e42d
@@ -761,15 +760,15 @@ _gcry_mpi_print (enum gcry_mpi_format fo
66e42d
       if (!n || (*tmp & 0x80))
66e42d
         extra = 2;
66e42d
 
66e42d
-      if (buffer && 2*n + extra + negative + 1 > len)
66e42d
-        {
66e42d
-          xfree(tmp);
66e42d
-          return GPG_ERR_TOO_SHORT;
66e42d
-	}
66e42d
       if (buffer)
66e42d
         {
66e42d
           unsigned char *s = buffer;
66e42d
 
66e42d
+          if (2*n + extra + negative + 1 > len)
66e42d
+            {
66e42d
+              xfree(tmp);
66e42d
+              return GPG_ERR_TOO_SHORT;
66e42d
+	    }
66e42d
           if (negative)
66e42d
             *s++ = '-';
66e42d
           if (extra)