diff options
| author | tb <> | 2024-08-30 17:26:44 +0000 |
|---|---|---|
| committer | tb <> | 2024-08-30 17:26:44 +0000 |
| commit | 0191f2decd866397df1b2c19c627901a64630be3 (patch) | |
| tree | 34c252eac883bbe51da9671ad78d63ef1c72733c /src | |
| parent | 9dd197533be1771b5403c1b52b645fdd4adfcc50 (diff) | |
| download | openbsd-0191f2decd866397df1b2c19c627901a64630be3.tar.gz openbsd-0191f2decd866397df1b2c19c627901a64630be3.tar.bz2 openbsd-0191f2decd866397df1b2c19c627901a64630be3.zip | |
Add and use local copy of X509V3_add_value()
The public API will be removed. This fixes its only consumer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/openssl/ocsp.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/usr.bin/openssl/ocsp.c b/src/usr.bin/openssl/ocsp.c index 945303c33c..ace843cce1 100644 --- a/src/usr.bin/openssl/ocsp.c +++ b/src/usr.bin/openssl/ocsp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ocsp.c,v 1.24 2024/08/29 11:04:02 tb Exp $ */ | 1 | /* $OpenBSD: ocsp.c,v 1.25 2024/08/30 17:26:44 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -70,6 +70,7 @@ | |||
| 70 | #include "apps.h" | 70 | #include "apps.h" |
| 71 | 71 | ||
| 72 | #include <openssl/bn.h> | 72 | #include <openssl/bn.h> |
| 73 | #include <openssl/conf.h> | ||
| 73 | #include <openssl/crypto.h> | 74 | #include <openssl/crypto.h> |
| 74 | #include <openssl/err.h> | 75 | #include <openssl/err.h> |
| 75 | #include <openssl/evp.h> | 76 | #include <openssl/evp.h> |
| @@ -185,12 +186,50 @@ ocsp_opt_cert_id_md(int argc, char **argv, int *argsused) | |||
| 185 | } | 186 | } |
| 186 | 187 | ||
| 187 | static int | 188 | static int |
| 189 | x509v3_add_value(const char *name, const char *value, | ||
| 190 | STACK_OF(CONF_VALUE) **extlist) | ||
| 191 | { | ||
| 192 | CONF_VALUE *vtmp = NULL; | ||
| 193 | STACK_OF(CONF_VALUE) *free_exts = NULL; | ||
| 194 | |||
| 195 | if ((vtmp = calloc(1, sizeof(CONF_VALUE))) == NULL) | ||
| 196 | goto err; | ||
| 197 | if (name != NULL) { | ||
| 198 | if ((vtmp->name = strdup(name)) == NULL) | ||
| 199 | goto err; | ||
| 200 | } | ||
| 201 | if (value != NULL) { | ||
| 202 | if ((vtmp->value = strdup(value)) == NULL) | ||
| 203 | goto err; | ||
| 204 | } | ||
| 205 | |||
| 206 | if (*extlist == NULL) { | ||
| 207 | if ((free_exts = *extlist = sk_CONF_VALUE_new_null()) == NULL) | ||
| 208 | goto err; | ||
| 209 | } | ||
| 210 | |||
| 211 | if (!sk_CONF_VALUE_push(*extlist, vtmp)) | ||
| 212 | goto err; | ||
| 213 | |||
| 214 | return 1; | ||
| 215 | |||
| 216 | err: | ||
| 217 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
| 218 | X509V3_conf_free(vtmp); | ||
| 219 | if (free_exts != NULL) { | ||
| 220 | sk_CONF_VALUE_free(*extlist); | ||
| 221 | *extlist = NULL; | ||
| 222 | } | ||
| 223 | return 0; | ||
| 224 | } | ||
| 225 | |||
| 226 | static int | ||
| 188 | ocsp_opt_header(int argc, char **argv, int *argsused) | 227 | ocsp_opt_header(int argc, char **argv, int *argsused) |
| 189 | { | 228 | { |
| 190 | if (argc < 3 || argv[1] == NULL || argv[2] == NULL) | 229 | if (argc < 3 || argv[1] == NULL || argv[2] == NULL) |
| 191 | return (1); | 230 | return (1); |
| 192 | 231 | ||
| 193 | if (!X509V3_add_value(argv[1], argv[2], &cfg.headers)) { | 232 | if (!x509v3_add_value(argv[1], argv[2], &cfg.headers)) { |
| 194 | cfg.no_usage = 1; | 233 | cfg.no_usage = 1; |
| 195 | return (1); | 234 | return (1); |
| 196 | } | 235 | } |
