=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/asn1pars.c,v retrieving revision 1.13 retrieving revision 1.14 diff -c -r1.13 -r1.14 *** src/usr.bin/openssl/asn1pars.c 2023/03/06 14:32:05 1.13 --- src/usr.bin/openssl/asn1pars.c 2023/03/07 05:53:17 1.14 *************** *** 1,4 **** ! /* $OpenBSD: asn1pars.c,v 1.13 2023/03/06 14:32:05 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * --- 1,4 ---- ! /* $OpenBSD: asn1pars.c,v 1.14 2023/03/07 05:53:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * *************** *** 267,273 **** in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); ! if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } --- 267,273 ---- in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); ! if (in == NULL || out == NULL) { ERR_print_errors(bio_err); goto end; } *************** *** 291,298 **** } } ! if (cfg.derfile) { ! if (!(derout = BIO_new_file(cfg.derfile, "wb"))) { BIO_printf(bio_err, "problems opening %s\n", cfg.derfile); ERR_print_errors(bio_err); --- 291,298 ---- } } ! if (cfg.derfile != NULL) { ! if ((derout = BIO_new_file(cfg.derfile, "wb")) == NULL) { BIO_printf(bio_err, "problems opening %s\n", cfg.derfile); ERR_print_errors(bio_err); *************** *** 302,318 **** if ((buf = BUF_MEM_new()) == NULL) goto end; if (!BUF_MEM_grow(buf, BUFSIZ * 8)) ! goto end; /* Pre-allocate :-) */ ! if (cfg.genstr || cfg.genconf) { ! num = do_generate(bio_err, cfg.genstr, ! cfg.genconf, buf); if (num < 0) { ERR_print_errors(bio_err); goto end; } } else { - if (cfg.informat == FORMAT_PEM) { BIO *tmp; --- 302,316 ---- if ((buf = BUF_MEM_new()) == NULL) goto end; if (!BUF_MEM_grow(buf, BUFSIZ * 8)) ! goto end; ! if (cfg.genstr != NULL || cfg.genconf) { ! num = do_generate(bio_err, cfg.genstr, cfg.genconf, buf); if (num < 0) { ERR_print_errors(bio_err); goto end; } } else { if (cfg.informat == FORMAT_PEM) { BIO *tmp; *************** *** 337,357 **** /* If any structs to parse go through in sequence */ ! if (sk_OPENSSL_STRING_num(cfg.osk)) { tmpbuf = (unsigned char *) str; tmplen = num; ! for (i = 0; i < sk_OPENSSL_STRING_num(cfg.osk); ! i++) { ASN1_TYPE *atmp; int typ; ! j = strtonum( ! sk_OPENSSL_STRING_value(cfg.osk, i), 1, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "'%s' is an invalid number: %s\n", ! sk_OPENSSL_STRING_value(cfg.osk, ! i), errstr); continue; } tmpbuf += j; --- 335,352 ---- /* If any structs to parse go through in sequence */ ! if (sk_OPENSSL_STRING_num(cfg.osk) > 0) { tmpbuf = (unsigned char *) str; tmplen = num; ! for (i = 0; i < sk_OPENSSL_STRING_num(cfg.osk); i++) { ASN1_TYPE *atmp; int typ; ! j = strtonum(sk_OPENSSL_STRING_value(cfg.osk, i), 1, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "'%s' is an invalid number: %s\n", ! sk_OPENSSL_STRING_value(cfg.osk, i), errstr); continue; } tmpbuf += j; *************** *** 366,373 **** goto end; } typ = ASN1_TYPE_get(at); ! if ((typ == V_ASN1_OBJECT) || ! (typ == V_ASN1_NULL)) { BIO_printf(bio_err, "Can't parse %s type\n", typ == V_ASN1_NULL ? "NULL" : "OBJECT"); ERR_print_errors(bio_err); --- 361,367 ---- goto end; } typ = ASN1_TYPE_get(at); ! if (typ == V_ASN1_OBJECT || typ == V_ASN1_NULL) { BIO_printf(bio_err, "Can't parse %s type\n", typ == V_ASN1_NULL ? "NULL" : "OBJECT"); ERR_print_errors(bio_err); *************** *** 386,395 **** } num -= cfg.offset; ! if ((cfg.length == 0) || ! ((long)cfg.length > num)) cfg.length = (unsigned int) num; ! if (derout) { if (BIO_write(derout, str + cfg.offset, cfg.length) != (int)cfg.length) { BIO_printf(bio_err, "Error writing output\n"); --- 380,388 ---- } num -= cfg.offset; ! if (cfg.length == 0 || (long)cfg.length > num) cfg.length = (unsigned int) num; ! if (derout != NULL) { if (BIO_write(derout, str + cfg.offset, cfg.length) != (int)cfg.length) { BIO_printf(bio_err, "Error writing output\n"); *************** *** 397,407 **** goto end; } } ! if (!cfg.noout && ! !ASN1_parse_dump(out, ! (unsigned char *)&(str[cfg.offset]), ! cfg.length, cfg.indent, ! cfg.dump)) { ERR_print_errors(bio_err); goto end; } --- 390,397 ---- goto end; } } ! if (!cfg.noout && !ASN1_parse_dump(out, ! (unsigned char *)&str[cfg.offset], cfg.length, cfg.indent, cfg.dump)) { ERR_print_errors(bio_err); goto end; }