~ubuntu-branches/ubuntu/vivid/gnupg2/vivid-proposed

« back to all changes in this revision

Viewing changes to g10/parse-packet.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2014-06-26 14:50:31 UTC
  • mfrom: (14.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20140626145031-tpg2xmbtvomb8erd
Tags: 2.0.24-1ubuntu1
* Merge from Debian, remaining changes:
  - Drop sh prefix from openpgp test environment as it leads to exec
    invocations of sh /bin/bash leading to syntax errors from sh.  Fixes
    FTBFS detected in Ubuntu saucy archive rebuild.
  - Add udev rules to give gpg access to some smartcard readers;
    Debian #543217.
  - debian/gnupg2.udev: udev rules to set ACLs on SCM smartcard readers.
  - Add upstart user job for gpg-agent.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
  /*FIXME: Needs to be synced with gnupg14/mpi/mpicoder.c*/
112
112
 
113
113
  int c, c1, c2, i;
 
114
  unsigned int nmax = *ret_nread;
114
115
  unsigned int nbits, nbytes;
115
116
  size_t nread = 0;
116
117
  gcry_mpi_t a = NULL;
117
118
  byte *buf = NULL;
118
119
  byte *p;
119
120
 
 
121
  if (!nmax)
 
122
    goto overflow;
 
123
 
120
124
  if ( (c = c1 = iobuf_get (inp)) == -1 )
121
125
    goto leave;
 
126
  if (++nread == nmax)
 
127
    goto overflow;
122
128
  nbits = c << 8;
123
129
  if ( (c = c2 = iobuf_get (inp)) == -1 )
124
130
    goto leave;
 
131
  ++nread;
125
132
  nbits |= c;
126
133
  if ( nbits > MAX_EXTERN_MPI_BITS )
127
134
    {
128
135
      log_error("mpi too large (%u bits)\n", nbits);
129
136
      goto leave;
130
137
    }
131
 
  nread = 2;
 
138
 
132
139
  nbytes = (nbits+7) / 8;
133
140
  buf = secure ? gcry_xmalloc_secure (nbytes + 2) : gcry_xmalloc (nbytes + 2);
134
141
  p = buf;
137
144
  for ( i=0 ; i < nbytes; i++ )
138
145
    {
139
146
      p[i+2] = iobuf_get(inp) & 0xff;
 
147
      if (nread == nmax)
 
148
        goto overflow;
140
149
      nread++;
141
150
    }
142
151
 
152
161
        a = NULL;
153
162
    }
154
163
 
 
164
  *ret_nread = nread;
 
165
  gcry_free(buf);
 
166
  return a;
 
167
 
 
168
 overflow:
 
169
  log_error ("mpi larger than indicated length (%u bits)\n", 8*nmax);
155
170
 leave:
 
171
  *ret_nread = nread;
156
172
  gcry_free(buf);
157
 
  if ( nread > *ret_nread )
158
 
    log_bug ("mpi larger than packet");
159
 
  else
160
 
    *ret_nread = nread;
161
173
  return a;
162
174
}
163
175