~ubuntu-branches/ubuntu/trusty/gnutls26/trusty

« back to all changes in this revision

Viewing changes to tests/cve-2008-4989.c

  • Committer: Package Import Robot
  • Author(s): Andreas Metzler
  • Date: 2011-10-01 15:28:13 UTC
  • mfrom: (12.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20111001152813-yygm1c4cxonfxhzy
* New upstream version.
  + Allow CA importing of 0 certificates to succeed. Closes: #640639
* Add libp11-kit-dev to libgnutls-dev dependencies. (see #643811)
* [20_guiledocstring.diff] guile: Fix docstring extraction with CPP 4.5+.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 */
22
22
 
23
23
#ifdef HAVE_CONFIG_H
24
 
# include <config.h>
 
24
#include <config.h>
25
25
#endif
26
26
 
27
27
#include <stdio.h>
165
165
    {
166
166
      ret = gnutls_x509_crt_init (&certs[i]);
167
167
      if (ret < 0)
168
 
        error (EXIT_FAILURE, 0, "gnutls_x509_crt_init[%d]: %s", (int) i,
169
 
               gnutls_strerror (ret));
 
168
        error (EXIT_FAILURE, 0, "gnutls_x509_crt_init[%d]: %s", (int) i,
 
169
               gnutls_strerror (ret));
170
170
 
171
171
      tmp.data = (char *) pem_certs[i];
172
172
      tmp.size = strlen (pem_certs[i]);
173
173
 
174
174
      ret = gnutls_x509_crt_import (certs[i], &tmp, GNUTLS_X509_FMT_PEM);
175
175
      if (ret < 0)
176
 
        error (EXIT_FAILURE, 0, "gnutls_x509_crt_import[%d]: %s", (int) i,
177
 
               gnutls_strerror (ret));
 
176
        error (EXIT_FAILURE, 0, "gnutls_x509_crt_import[%d]: %s", (int) i,
 
177
               gnutls_strerror (ret));
178
178
    }
179
179
 
180
180
  ret = gnutls_x509_crt_init (&ca);
181
181
  if (ret < 0)
182
182
    error (EXIT_FAILURE, 0, "gnutls_x509_crt_init: %s",
183
 
           gnutls_strerror (ret));
 
183
           gnutls_strerror (ret));
184
184
 
185
185
  tmp.data = (char *) pem_ca;
186
186
  tmp.size = strlen (pem_ca);
188
188
  ret = gnutls_x509_crt_import (ca, &tmp, GNUTLS_X509_FMT_PEM);
189
189
  if (ret < 0)
190
190
    error (EXIT_FAILURE, 0, "gnutls_x509_crt_import: %s",
191
 
           gnutls_strerror (ret));
 
191
           gnutls_strerror (ret));
192
192
 
193
193
  ret = gnutls_x509_crt_list_verify (certs, CHAIN_LENGTH,
194
 
                                     &ca, 1,
195
 
                                     NULL, 0,
196
 
                                     GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
197
 
                                     &verify_status);
 
194
                                     &ca, 1,
 
195
                                     NULL, 0,
 
196
                                     GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
 
197
                                     &verify_status);
198
198
  if (ret < 0)
199
199
    error (EXIT_FAILURE, 0, "gnutls_x509_crt_list_verify[%d]: %s", (int) i,
200
 
           gnutls_strerror (ret));
 
200
           gnutls_strerror (ret));
201
201
 
202
202
  if (verify_status != (GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID))
203
203
    error (EXIT_FAILURE, 0, "verify_status: %d", verify_status);
212
212
  ret = gnutls_x509_crt_init (&self_cert);
213
213
  if (ret < 0)
214
214
    error (EXIT_FAILURE, 0, "gnutls_x509_crt_init: %s",
215
 
           gnutls_strerror (ret));
 
215
           gnutls_strerror (ret));
216
216
 
217
217
  tmp.data = (char *) pem_self_cert;
218
218
  tmp.size = strlen (pem_self_cert);
220
220
  ret = gnutls_x509_crt_import (self_cert, &tmp, GNUTLS_X509_FMT_PEM);
221
221
  if (ret < 0)
222
222
    error (EXIT_FAILURE, 0, "gnutls_x509_crt_import: %s",
223
 
           gnutls_strerror (ret));
 
223
           gnutls_strerror (ret));
224
224
 
225
225
  ret = gnutls_x509_crt_list_verify (&self_cert, 1,
226
 
                                     &self_cert, 1,
227
 
                                     NULL, 0,
228
 
                                     GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
229
 
                                     &verify_status);
 
226
                                     &self_cert, 1,
 
227
                                     NULL, 0,
 
228
                                     GNUTLS_VERIFY_DISABLE_TIME_CHECKS,
 
229
                                     &verify_status);
230
230
  if (ret < 0)
231
231
    error (EXIT_FAILURE, 0, "gnutls_x509_crt_list_verify[%d]: %s", (int) i,
232
 
           gnutls_strerror (ret));
 
232
           gnutls_strerror (ret));
233
233
 
234
234
  if (verify_status != 0)
235
235
    error (EXIT_FAILURE, 0, "verify_status: %d", verify_status);