~ubuntu-branches/ubuntu/utopic/openssl/utopic

« back to all changes in this revision

Viewing changes to apps/engine.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2011-04-02 13:19:19 UTC
  • mfrom: (1.2.1 upstream) (11.2.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 55.
  • Revision ID: james.westby@ubuntu.com-20110402131919-anszuslper64ey9e
Tags: 1.0.0d-1
* New upstream version
  - Fixes CVE-2011-0014
* Make libssl-doc Replaces/Breaks with old libssl-dev packages
  (Closes: #607609)
* Only export the symbols we should, instead of all.
* Add symbol file.
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
NULL
93
93
};
94
94
 
95
 
static void identity(void *ptr)
 
95
static void identity(char *ptr)
96
96
        {
97
97
        return;
98
98
        }
148
148
 
149
149
        if(flags & ENGINE_CMD_FLAG_NUMERIC)
150
150
                {
151
 
                if(started)
152
 
                        {
153
 
                        BIO_printf(bio_out, "|");
154
 
                        err = 1;
155
 
                        }
156
151
                BIO_printf(bio_out, "NUMERIC");
157
152
                started = 1;
158
153
                }
205
200
        char *desc = NULL;
206
201
        int flags;
207
202
        int xpos = 0;
208
 
        STACK *cmds = NULL;
 
203
        STACK_OF(OPENSSL_STRING) *cmds = NULL;
209
204
        if(!ENGINE_ctrl(e, ENGINE_CTRL_HAS_CTRL_FUNCTION, 0, NULL, NULL) ||
210
205
                        ((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_FIRST_CMD_TYPE,
211
206
                                        0, NULL, NULL)) <= 0))
216
211
                return 1;
217
212
                }
218
213
 
219
 
        cmds = sk_new_null();
 
214
        cmds = sk_OPENSSL_STRING_new_null();
220
215
 
221
216
        if(!cmds)
222
217
                goto err;
289
284
                BIO_printf(bio_out, "\n");
290
285
        ret = 1;
291
286
err:
292
 
        if(cmds) sk_pop_free(cmds, identity);
 
287
        if(cmds) sk_OPENSSL_STRING_pop_free(cmds, identity);
293
288
        if(name) OPENSSL_free(name);
294
289
        if(desc) OPENSSL_free(desc);
295
290
        return ret;
296
291
        }
297
292
 
298
 
static void util_do_cmds(ENGINE *e, STACK *cmds, BIO *bio_out, const char *indent)
 
293
static void util_do_cmds(ENGINE *e, STACK_OF(OPENSSL_STRING) *cmds,
 
294
                        BIO *bio_out, const char *indent)
299
295
        {
300
 
        int loop, res, num = sk_num(cmds);
 
296
        int loop, res, num = sk_OPENSSL_STRING_num(cmds);
 
297
 
301
298
        if(num < 0)
302
299
                {
303
300
                BIO_printf(bio_out, "[Error]: internal stack error\n");
307
304
                {
308
305
                char buf[256];
309
306
                const char *cmd, *arg;
310
 
                cmd = sk_value(cmds, loop);
 
307
                cmd = sk_OPENSSL_STRING_value(cmds, loop);
311
308
                res = 1; /* assume success */
312
309
                /* Check if this command has no ":arg" */
313
310
                if((arg = strstr(cmd, ":")) == NULL)
347
344
        const char **pp;
348
345
        int verbose=0, list_cap=0, test_avail=0, test_avail_noise = 0;
349
346
        ENGINE *e;
350
 
        STACK *engines = sk_new_null();
351
 
        STACK *pre_cmds = sk_new_null();
352
 
        STACK *post_cmds = sk_new_null();
 
347
        STACK_OF(OPENSSL_STRING) *engines = sk_OPENSSL_STRING_new_null();
 
348
        STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
 
349
        STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();
353
350
        int badops=1;
354
351
        BIO *bio_out=NULL;
355
352
        const char *indent = "     ";
396
393
                        argc--; argv++;
397
394
                        if (argc == 0)
398
395
                                goto skip_arg_loop;
399
 
                        sk_push(pre_cmds,*argv);
 
396
                        sk_OPENSSL_STRING_push(pre_cmds,*argv);
400
397
                        }
401
398
                else if (strcmp(*argv,"-post") == 0)
402
399
                        {
403
400
                        argc--; argv++;
404
401
                        if (argc == 0)
405
402
                                goto skip_arg_loop;
406
 
                        sk_push(post_cmds,*argv);
 
403
                        sk_OPENSSL_STRING_push(post_cmds,*argv);
407
404
                        }
408
405
                else if ((strncmp(*argv,"-h",2) == 0) ||
409
406
                                (strcmp(*argv,"-?") == 0))
410
407
                        goto skip_arg_loop;
411
408
                else
412
 
                        sk_push(engines,*argv);
 
409
                        sk_OPENSSL_STRING_push(engines,*argv);
413
410
                argc--;
414
411
                argv++;
415
412
                }
424
421
                goto end;
425
422
                }
426
423
 
427
 
        if (sk_num(engines) == 0)
 
424
        if (sk_OPENSSL_STRING_num(engines) == 0)
428
425
                {
429
426
                for(e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e))
430
427
                        {
431
 
                        sk_push(engines,(char *)ENGINE_get_id(e));
 
428
                        sk_OPENSSL_STRING_push(engines,(char *)ENGINE_get_id(e));
432
429
                        }
433
430
                }
434
431
 
435
 
        for (i=0; i<sk_num(engines); i++)
 
432
        for (i=0; i<sk_OPENSSL_STRING_num(engines); i++)
436
433
                {
437
 
                const char *id = sk_value(engines,i);
 
434
                const char *id = sk_OPENSSL_STRING_value(engines,i);
438
435
                if ((e = ENGINE_by_id(id)) != NULL)
439
436
                        {
440
437
                        const char *name = ENGINE_get_name(e);
454
451
                                const int *nids;
455
452
                                ENGINE_CIPHERS_PTR fn_c;
456
453
                                ENGINE_DIGESTS_PTR fn_d;
 
454
                                ENGINE_PKEY_METHS_PTR fn_pk;
457
455
 
458
456
                                if (ENGINE_get_RSA(e) != NULL
459
457
                                        && !append_buf(&cap_buf, "RSA",
492
490
                                                goto end;
493
491
 
494
492
skip_digests:
 
493
                                fn_pk = ENGINE_get_pkey_meths(e);
 
494
                                if(!fn_pk) goto skip_pmeths;
 
495
                                n = fn_pk(e, NULL, &nids, 0);
 
496
                                for(k=0 ; k < n ; ++k)
 
497
                                        if(!append_buf(&cap_buf,
 
498
                                                       OBJ_nid2sn(nids[k]),
 
499
                                                       &cap_size, 256))
 
500
                                                goto end;
 
501
skip_pmeths:
495
502
                                if (cap_buf && (*cap_buf != '\0'))
496
503
                                        BIO_printf(bio_out, " [%s]\n", cap_buf);
497
504
 
526
533
end:
527
534
 
528
535
        ERR_print_errors(bio_err);
529
 
        sk_pop_free(engines, identity);
530
 
        sk_pop_free(pre_cmds, identity);
531
 
        sk_pop_free(post_cmds, identity);
 
536
        sk_OPENSSL_STRING_pop_free(engines, identity);
 
537
        sk_OPENSSL_STRING_pop_free(pre_cmds, identity);
 
538
        sk_OPENSSL_STRING_pop_free(post_cmds, identity);
532
539
        if (bio_out != NULL) BIO_free_all(bio_out);
533
540
        apps_shutdown();
534
541
        OPENSSL_EXIT(ret);