~andersk/ubuntu/oneiric/openssl/spurious-reboot

« back to all changes in this revision

Viewing changes to crypto/ocsp/ocsp_ht.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-01 23:51:53 UTC
  • mfrom: (11.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20110501235153-bjcxitndquaezb68
Tags: 1.0.0d-2ubuntu1
* Resynchronise with Debian (LP: #675566).  Remaining changes:
  - debian/libssl1.0.0.postinst:
    + Display a system restart required notification bubble on libssl1.0.0
      upgrade.
    + Use a different priority for libssl1.0.0/restart-services depending
      on whether a desktop, or server dist-upgrade is being performed.
  - debian/{libssl1.0.0-udeb.dirs, control, rules}: Create
    libssl1.0.0-udeb, for the benefit of wget-udeb (no wget-udeb package
    in Debian).
  - debian/{libcrypto1.0.0-udeb.dirs, libssl1.0.0.dirs, libssl1.0.0.files,
    rules}: Move runtime libraries to /lib, for the benefit of
    wpasupplicant.
  - debian/patches/aesni.patch: Backport Intel AES-NI support, now from
    http://rt.openssl.org/Ticket/Display.html?id=2065 rather than the
    0.9.8 variant.
  - debian/patches/Bsymbolic-functions.patch: Link using
    -Bsymbolic-functions.
  - debian/patches/perlpath-quilt.patch: Don't change perl #! paths under
    .pc.
  - debian/rules:
    + Don't run 'make test' when cross-building.
    + Use host compiler when cross-building.  Patch from Neil Williams.
    + Don't build for processors no longer supported: i486, i586 (on
      i386), v8 (on sparc).
    + Fix Makefile to properly clean up libs/ dirs in clean target.
    + Replace duplicate files in the doc directory with symlinks.
* Update architectures affected by Bsymbolic-functions.patch.
* Drop debian/patches/no-sslv2.patch; Debian now adds the 'no-ssl2'
  configure option, which compiles out SSLv2 support entirely, so this is
  no longer needed.
* Drop openssl-doc in favour of the libssl-doc package introduced by
  Debian.  Add Conflicts/Replaces until the next LTS release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        OPENSSL_free(rctx);
119
119
        }
120
120
 
 
121
int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req)
 
122
        {
 
123
        static const char req_hdr[] =
 
124
        "Content-Type: application/ocsp-request\r\n"
 
125
        "Content-Length: %d\r\n\r\n";
 
126
        if (BIO_printf(rctx->mem, req_hdr, i2d_OCSP_REQUEST(req, NULL)) <= 0)
 
127
                return 0;
 
128
        if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0)
 
129
                return 0;
 
130
        rctx->state = OHS_ASN1_WRITE;
 
131
        rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
 
132
        return 1;
 
133
        }
 
134
 
 
135
int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
 
136
                const char *name, const char *value)
 
137
        {
 
138
        if (!name)
 
139
                return 0;
 
140
        if (BIO_puts(rctx->mem, name) <= 0)
 
141
                return 0;
 
142
        if (value)
 
143
                {
 
144
                if (BIO_write(rctx->mem, ": ", 2) != 2)
 
145
                        return 0;
 
146
                if (BIO_puts(rctx->mem, value) <= 0)
 
147
                        return 0;
 
148
                }
 
149
        if (BIO_write(rctx->mem, "\r\n", 2) != 2)
 
150
                return 0;
 
151
        return 1;
 
152
        }
 
153
 
121
154
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
122
155
                                                                int maxline)
123
156
        {
124
 
        static char post_hdr[] = "POST %s HTTP/1.0\r\n"
125
 
        "Content-Type: application/ocsp-request\r\n"
126
 
        "Content-Length: %d\r\n\r\n";
 
157
        static const char post_hdr[] = "POST %s HTTP/1.0\r\n";
127
158
 
128
159
        OCSP_REQ_CTX *rctx;
129
160
        rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX));
130
 
        rctx->state = OHS_FIRSTLINE;
 
161
        rctx->state = OHS_ERROR;
131
162
        rctx->mem = BIO_new(BIO_s_mem());
132
163
        rctx->io = io;
 
164
        rctx->asn1_len = 0;
133
165
        if (maxline > 0)
134
166
                rctx->iobuflen = maxline;
135
167
        else
136
168
                rctx->iobuflen = OCSP_MAX_LINE_LEN;
137
169
        rctx->iobuf = OPENSSL_malloc(rctx->iobuflen);
 
170
        if (!rctx->iobuf)
 
171
                return 0;
138
172
        if (!path)
139
173
                path = "/";
140
174
 
141
 
        if (BIO_printf(rctx->mem, post_hdr, path,
142
 
                                i2d_OCSP_REQUEST(req, NULL)) <= 0)
143
 
                {
144
 
                rctx->state = OHS_ERROR;
145
 
                return 0;
146
 
                }
147
 
        if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0)
148
 
                {
149
 
                rctx->state = OHS_ERROR;
150
 
                return 0;
151
 
                }
152
 
        rctx->state = OHS_ASN1_WRITE;
153
 
        rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
 
175
        if (BIO_printf(rctx->mem, post_hdr, path) <= 0)
 
176
                return 0;
 
177
 
 
178
        if (req && !OCSP_REQ_CTX_set1_req(rctx, req))
 
179
                return 0;
154
180
 
155
181
        return rctx;
156
182
        }
371
397
 
372
398
 
373
399
                case OHS_ASN1_HEADER:
374
 
                /* Now reading ASN1 header: can read at least 6 bytes which
375
 
                 * is more than enough for any valid ASN1 SEQUENCE header
 
400
                /* Now reading ASN1 header: can read at least 2 bytes which
 
401
                 * is enough for ASN1 SEQUENCE header and either length field
 
402
                 * or at least the length of the length field.
376
403
                 */
377
404
                n = BIO_get_mem_data(rctx->mem, &p);
378
 
                if (n < 6)
 
405
                if (n < 2)
379
406
                        goto next_io;
380
407
 
381
408
                /* Check it is an ASN1 SEQUENCE */
388
415
                /* Check out length field */
389
416
                if (*p & 0x80)
390
417
                        {
 
418
                        /* If MSB set on initial length octet we can now
 
419
                         * always read 6 octets: make sure we have them.
 
420
                         */
 
421
                        if (n < 6)
 
422
                                goto next_io;
391
423
                        n = *p & 0x7F;
392
424
                        /* Not NDEF or excessive length */
393
425
                        if (!n || (n > 4))