summaryrefslogtreecommitdiff
path: root/packages/gnupg/gnupg-1.4.2.2/22_zero_length_mpi_fix.patch
blob: 8f13db4d238df67ac57a95e92de2031551e5fa03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
diff -urNad gnupg-1.4.2~/mpi/mpicoder.c gnupg-1.4.2/mpi/mpicoder.c
--- gnupg-1.4.2~/mpi/mpicoder.c	2005-05-31 06:30:05.000000000 +0000
+++ gnupg-1.4.2/mpi/mpicoder.c	2005-09-29 00:52:19.000000000 +0000
@@ -80,16 +80,20 @@
     mpi_limb_t a;
     MPI val = MPI_NULL;
 
+    if (nread == nmax)
+        goto overflow;
     if( (c = iobuf_get(inp)) == -1 )
 	goto leave;
-    if (++nread >= nmax)
-        goto overflow;
+    nread++;
     nbits = c << 8;
+
+    if (nread == nmax)
+        goto overflow;
     if( (c = iobuf_get(inp)) == -1 )
 	goto leave;
-    if (++nread >= nmax)
-        goto overflow;
+    nread++;
     nbits |= c;
+
     if( nbits > MAX_EXTERN_MPI_BITS ) {
 	log_error("mpi too large for this implementation (%u bits)\n", nbits);
 	goto leave;
@@ -112,7 +116,7 @@
     for( ; j > 0; j-- ) {
 	a = 0;
 	for(; i < BYTES_PER_MPI_LIMB; i++ ) {
-            if (nread >= nmax) {
+            if (nread == nmax) {
 #ifdef M_DEBUG
                 mpi_debug_free (val);
 #else