diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/x509/x509_lib.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/lib/libcrypto/x509/x509_lib.c b/src/lib/libcrypto/x509/x509_lib.c index 161e638427..8382babbdf 100644 --- a/src/lib/libcrypto/x509/x509_lib.c +++ b/src/lib/libcrypto/x509/x509_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_lib.c,v 1.22 2024/06/17 05:31:26 tb Exp $ */ | 1 | /* $OpenBSD: x509_lib.c,v 1.23 2024/06/17 05:38:08 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 1999. | 3 | * project 1999. |
| 4 | */ | 4 | */ |
| @@ -187,7 +187,8 @@ LCRYPTO_ALIAS(X509V3_EXT_d2i); | |||
| 187 | */ | 187 | */ |
| 188 | 188 | ||
| 189 | void * | 189 | void * |
| 190 | X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) | 190 | X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x509_exts, int nid, int *crit, |
| 191 | int *idx) | ||
| 191 | { | 192 | { |
| 192 | X509_EXTENSION *ext; | 193 | X509_EXTENSION *ext; |
| 193 | int lastpos = idx == NULL ? -1 : *idx; | 194 | int lastpos = idx == NULL ? -1 : *idx; |
| @@ -201,11 +202,11 @@ X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) | |||
| 201 | * Nothing to do if no extensions, unknown nid, or missing extension. | 202 | * Nothing to do if no extensions, unknown nid, or missing extension. |
| 202 | */ | 203 | */ |
| 203 | 204 | ||
| 204 | if (x == NULL) | 205 | if (x509_exts == NULL) |
| 205 | return NULL; | 206 | return NULL; |
| 206 | if ((lastpos = X509v3_get_ext_by_NID(x, nid, lastpos)) < 0) | 207 | if ((lastpos = X509v3_get_ext_by_NID(x509_exts, nid, lastpos)) < 0) |
| 207 | return NULL; | 208 | return NULL; |
| 208 | if ((ext = X509v3_get_ext(x, lastpos)) == NULL) | 209 | if ((ext = X509v3_get_ext(x509_exts, lastpos)) == NULL) |
| 209 | return NULL; | 210 | return NULL; |
| 210 | 211 | ||
| 211 | /* | 212 | /* |
| @@ -214,7 +215,7 @@ X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) | |||
| 214 | * don't care and set *idx to the index of the first extension found. | 215 | * don't care and set *idx to the index of the first extension found. |
| 215 | */ | 216 | */ |
| 216 | 217 | ||
| 217 | if (idx == NULL && X509v3_get_ext_by_NID(x, nid, lastpos) > 0) { | 218 | if (idx == NULL && X509v3_get_ext_by_NID(x509_exts, nid, lastpos) > 0) { |
| 218 | if (crit != NULL) | 219 | if (crit != NULL) |
| 219 | *crit = -2; | 220 | *crit = -2; |
| 220 | return NULL; | 221 | return NULL; |
| @@ -236,10 +237,10 @@ X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) | |||
| 236 | LCRYPTO_ALIAS(X509V3_get_d2i); | 237 | LCRYPTO_ALIAS(X509V3_get_d2i); |
| 237 | 238 | ||
| 238 | int | 239 | int |
| 239 | X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | 240 | X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x509_exts, int nid, void *value, |
| 240 | int crit, unsigned long flags) | 241 | int crit, unsigned long flags) |
| 241 | { | 242 | { |
| 242 | STACK_OF(X509_EXTENSION) *exts = *x; | 243 | STACK_OF(X509_EXTENSION) *exts = *x509_exts; |
| 243 | X509_EXTENSION *ext = NULL; | 244 | X509_EXTENSION *ext = NULL; |
| 244 | X509_EXTENSION *existing; | 245 | X509_EXTENSION *existing; |
| 245 | int extidx; | 246 | int extidx; |
| @@ -247,7 +248,7 @@ X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | |||
| 247 | int ret = 0; | 248 | int ret = 0; |
| 248 | 249 | ||
| 249 | /* See if the extension already exists. */ | 250 | /* See if the extension already exists. */ |
| 250 | extidx = X509v3_get_ext_by_NID(*x, nid, -1); | 251 | extidx = X509v3_get_ext_by_NID(*x509_exts, nid, -1); |
| 251 | 252 | ||
| 252 | switch (flags & X509V3_ADD_OP_MASK) { | 253 | switch (flags & X509V3_ADD_OP_MASK) { |
| 253 | case X509V3_ADD_DEFAULT: | 254 | case X509V3_ADD_DEFAULT: |
| @@ -287,7 +288,8 @@ X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | |||
| 287 | errcode = X509V3_R_EXTENSION_NOT_FOUND; | 288 | errcode = X509V3_R_EXTENSION_NOT_FOUND; |
| 288 | goto err; | 289 | goto err; |
| 289 | } | 290 | } |
| 290 | if ((existing = sk_X509_EXTENSION_delete(*x, extidx)) == NULL) { | 291 | if ((existing = sk_X509_EXTENSION_delete(*x509_exts, |
| 292 | extidx)) == NULL) { | ||
| 291 | ret = -1; | 293 | ret = -1; |
| 292 | goto err; | 294 | goto err; |
| 293 | } | 295 | } |
| @@ -310,10 +312,10 @@ X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | |||
| 310 | 312 | ||
| 311 | /* If extension exists, replace it. */ | 313 | /* If extension exists, replace it. */ |
| 312 | if (extidx >= 0) { | 314 | if (extidx >= 0) { |
| 313 | existing = sk_X509_EXTENSION_value(*x, extidx); | 315 | existing = sk_X509_EXTENSION_value(*x509_exts, extidx); |
| 314 | X509_EXTENSION_free(existing); | 316 | X509_EXTENSION_free(existing); |
| 315 | existing = NULL; | 317 | existing = NULL; |
| 316 | if (sk_X509_EXTENSION_set(*x, extidx, ext) == NULL) { | 318 | if (sk_X509_EXTENSION_set(*x509_exts, extidx, ext) == NULL) { |
| 317 | /* | 319 | /* |
| 318 | * XXX - Can't happen. If it did happen, |existing| is | 320 | * XXX - Can't happen. If it did happen, |existing| is |
| 319 | * now a freed pointer. Nothing we can do here. | 321 | * now a freed pointer. Nothing we can do here. |
| @@ -332,7 +334,7 @@ X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | |||
| 332 | goto err; | 334 | goto err; |
| 333 | ext = NULL; | 335 | ext = NULL; |
| 334 | 336 | ||
| 335 | *x = exts; | 337 | *x509_exts = exts; |
| 336 | 338 | ||
| 337 | done: | 339 | done: |
| 338 | return 1; | 340 | return 1; |
| @@ -341,7 +343,7 @@ X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | |||
| 341 | if ((flags & X509V3_ADD_SILENT) == 0 && errcode != 0) | 343 | if ((flags & X509V3_ADD_SILENT) == 0 && errcode != 0) |
| 342 | X509V3error(errcode); | 344 | X509V3error(errcode); |
| 343 | 345 | ||
| 344 | if (exts != *x) | 346 | if (exts != *x509_exts) |
| 345 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); | 347 | sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); |
| 346 | X509_EXTENSION_free(ext); | 348 | X509_EXTENSION_free(ext); |
| 347 | 349 | ||
