diff options
| author | beck <> | 2017-01-29 17:49:23 +0000 |
|---|---|---|
| committer | beck <> | 2017-01-29 17:49:23 +0000 |
| commit | d1f47bd292f36094480caa49ada36b99a69c59b0 (patch) | |
| tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/x509v3/v3_utl.c | |
| parent | f8c627888330b75c2eea8a3c27d0efe947a4f9da (diff) | |
| download | openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.tar.gz openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.tar.bz2 openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.zip | |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3_utl.c')
| -rw-r--r-- | src/lib/libcrypto/x509v3/v3_utl.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_utl.c b/src/lib/libcrypto/x509v3/v3_utl.c index 7516cd3c20..04c789922b 100644 --- a/src/lib/libcrypto/x509v3/v3_utl.c +++ b/src/lib/libcrypto/x509v3/v3_utl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: v3_utl.c,v 1.25 2016/09/03 11:56:33 beck Exp $ */ | 1 | /* $OpenBSD: v3_utl.c,v 1.26 2017/01/29 17:49:23 beck 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. | 3 | * project. |
| 4 | */ | 4 | */ |
| @@ -103,7 +103,7 @@ X509V3_add_value(const char *name, const char *value, | |||
| 103 | return 1; | 103 | return 1; |
| 104 | 104 | ||
| 105 | err: | 105 | err: |
| 106 | X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE); | 106 | X509V3error(ERR_R_MALLOC_FAILURE); |
| 107 | free(vtmp); | 107 | free(vtmp); |
| 108 | free(tname); | 108 | free(tname); |
| 109 | free(tvalue); | 109 | free(tvalue); |
| @@ -159,7 +159,7 @@ i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *a) | |||
| 159 | return NULL; | 159 | return NULL; |
| 160 | if (!(bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) || | 160 | if (!(bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) || |
| 161 | !(strtmp = BN_bn2dec(bntmp))) | 161 | !(strtmp = BN_bn2dec(bntmp))) |
| 162 | X509V3err(X509V3_F_I2S_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); | 162 | X509V3error(ERR_R_MALLOC_FAILURE); |
| 163 | BN_free(bntmp); | 163 | BN_free(bntmp); |
| 164 | return strtmp; | 164 | return strtmp; |
| 165 | } | 165 | } |
| @@ -174,7 +174,7 @@ i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, ASN1_INTEGER *a) | |||
| 174 | return NULL; | 174 | return NULL; |
| 175 | if (!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) || | 175 | if (!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) || |
| 176 | !(strtmp = BN_bn2dec(bntmp))) | 176 | !(strtmp = BN_bn2dec(bntmp))) |
| 177 | X509V3err(X509V3_F_I2S_ASN1_INTEGER, ERR_R_MALLOC_FAILURE); | 177 | X509V3error(ERR_R_MALLOC_FAILURE); |
| 178 | BN_free(bntmp); | 178 | BN_free(bntmp); |
| 179 | return strtmp; | 179 | return strtmp; |
| 180 | } | 180 | } |
| @@ -188,8 +188,7 @@ s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) | |||
| 188 | int ret; | 188 | int ret; |
| 189 | 189 | ||
| 190 | if (!value) { | 190 | if (!value) { |
| 191 | X509V3err(X509V3_F_S2I_ASN1_INTEGER, | 191 | X509V3error(X509V3_R_INVALID_NULL_VALUE); |
| 192 | X509V3_R_INVALID_NULL_VALUE); | ||
| 193 | return 0; | 192 | return 0; |
| 194 | } | 193 | } |
| 195 | bn = BN_new(); | 194 | bn = BN_new(); |
| @@ -212,7 +211,7 @@ s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) | |||
| 212 | 211 | ||
| 213 | if (!ret || value[ret]) { | 212 | if (!ret || value[ret]) { |
| 214 | BN_free(bn); | 213 | BN_free(bn); |
| 215 | X509V3err(X509V3_F_S2I_ASN1_INTEGER, X509V3_R_BN_DEC2BN_ERROR); | 214 | X509V3error(X509V3_R_BN_DEC2BN_ERROR); |
| 216 | return 0; | 215 | return 0; |
| 217 | } | 216 | } |
| 218 | 217 | ||
| @@ -222,8 +221,7 @@ s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, char *value) | |||
| 222 | aint = BN_to_ASN1_INTEGER(bn, NULL); | 221 | aint = BN_to_ASN1_INTEGER(bn, NULL); |
| 223 | BN_free(bn); | 222 | BN_free(bn); |
| 224 | if (!aint) { | 223 | if (!aint) { |
| 225 | X509V3err(X509V3_F_S2I_ASN1_INTEGER, | 224 | X509V3error(X509V3_R_BN_TO_ASN1_INTEGER_ERROR); |
| 226 | X509V3_R_BN_TO_ASN1_INTEGER_ERROR); | ||
| 227 | return 0; | 225 | return 0; |
| 228 | } | 226 | } |
| 229 | if (isneg) | 227 | if (isneg) |
| @@ -267,8 +265,7 @@ X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool) | |||
| 267 | } | 265 | } |
| 268 | 266 | ||
| 269 | err: | 267 | err: |
| 270 | X509V3err(X509V3_F_X509V3_GET_VALUE_BOOL, | 268 | X509V3error(X509V3_R_INVALID_BOOLEAN_STRING); |
| 271 | X509V3_R_INVALID_BOOLEAN_STRING); | ||
| 272 | X509V3_conf_err(value); | 269 | X509V3_conf_err(value); |
| 273 | return 0; | 270 | return 0; |
| 274 | } | 271 | } |
| @@ -302,7 +299,7 @@ X509V3_parse_list(const char *line) | |||
| 302 | 299 | ||
| 303 | /* We are going to modify the line so copy it first */ | 300 | /* We are going to modify the line so copy it first */ |
| 304 | if ((linebuf = strdup(line)) == NULL) { | 301 | if ((linebuf = strdup(line)) == NULL) { |
| 305 | X509V3err(X509V3_F_X509V3_PARSE_LIST, ERR_R_MALLOC_FAILURE); | 302 | X509V3error(ERR_R_MALLOC_FAILURE); |
| 306 | goto err; | 303 | goto err; |
| 307 | } | 304 | } |
| 308 | state = HDR_NAME; | 305 | state = HDR_NAME; |
| @@ -319,8 +316,7 @@ X509V3_parse_list(const char *line) | |||
| 319 | *p = 0; | 316 | *p = 0; |
| 320 | ntmp = strip_spaces(q); | 317 | ntmp = strip_spaces(q); |
| 321 | if (!ntmp) { | 318 | if (!ntmp) { |
| 322 | X509V3err(X509V3_F_X509V3_PARSE_LIST, | 319 | X509V3error(X509V3_R_INVALID_NULL_NAME); |
| 323 | X509V3_R_INVALID_NULL_NAME); | ||
| 324 | goto err; | 320 | goto err; |
| 325 | } | 321 | } |
| 326 | q = p + 1; | 322 | q = p + 1; |
| @@ -329,8 +325,7 @@ X509V3_parse_list(const char *line) | |||
| 329 | ntmp = strip_spaces(q); | 325 | ntmp = strip_spaces(q); |
| 330 | q = p + 1; | 326 | q = p + 1; |
| 331 | if (!ntmp) { | 327 | if (!ntmp) { |
| 332 | X509V3err(X509V3_F_X509V3_PARSE_LIST, | 328 | X509V3error(X509V3_R_INVALID_NULL_NAME); |
| 333 | X509V3_R_INVALID_NULL_NAME); | ||
| 334 | goto err; | 329 | goto err; |
| 335 | } | 330 | } |
| 336 | X509V3_add_value(ntmp, NULL, &values); | 331 | X509V3_add_value(ntmp, NULL, &values); |
| @@ -343,8 +338,7 @@ X509V3_parse_list(const char *line) | |||
| 343 | *p = 0; | 338 | *p = 0; |
| 344 | vtmp = strip_spaces(q); | 339 | vtmp = strip_spaces(q); |
| 345 | if (!vtmp) { | 340 | if (!vtmp) { |
| 346 | X509V3err(X509V3_F_X509V3_PARSE_LIST, | 341 | X509V3error(X509V3_R_INVALID_NULL_VALUE); |
| 347 | X509V3_R_INVALID_NULL_VALUE); | ||
| 348 | goto err; | 342 | goto err; |
| 349 | } | 343 | } |
| 350 | X509V3_add_value(ntmp, vtmp, &values); | 344 | X509V3_add_value(ntmp, vtmp, &values); |
| @@ -358,16 +352,14 @@ X509V3_parse_list(const char *line) | |||
| 358 | if (state == HDR_VALUE) { | 352 | if (state == HDR_VALUE) { |
| 359 | vtmp = strip_spaces(q); | 353 | vtmp = strip_spaces(q); |
| 360 | if (!vtmp) { | 354 | if (!vtmp) { |
| 361 | X509V3err(X509V3_F_X509V3_PARSE_LIST, | 355 | X509V3error(X509V3_R_INVALID_NULL_VALUE); |
| 362 | X509V3_R_INVALID_NULL_VALUE); | ||
| 363 | goto err; | 356 | goto err; |
| 364 | } | 357 | } |
| 365 | X509V3_add_value(ntmp, vtmp, &values); | 358 | X509V3_add_value(ntmp, vtmp, &values); |
| 366 | } else { | 359 | } else { |
| 367 | ntmp = strip_spaces(q); | 360 | ntmp = strip_spaces(q); |
| 368 | if (!ntmp) { | 361 | if (!ntmp) { |
| 369 | X509V3err(X509V3_F_X509V3_PARSE_LIST, | 362 | X509V3error(X509V3_R_INVALID_NULL_NAME); |
| 370 | X509V3_R_INVALID_NULL_NAME); | ||
| 371 | goto err; | 363 | goto err; |
| 372 | } | 364 | } |
| 373 | X509V3_add_value(ntmp, NULL, &values); | 365 | X509V3_add_value(ntmp, NULL, &values); |
| @@ -420,7 +412,7 @@ hex_to_string(const unsigned char *buffer, long len) | |||
| 420 | if (!buffer || !len) | 412 | if (!buffer || !len) |
| 421 | return NULL; | 413 | return NULL; |
| 422 | if (!(tmp = malloc(len * 3 + 1))) { | 414 | if (!(tmp = malloc(len * 3 + 1))) { |
| 423 | X509V3err(X509V3_F_HEX_TO_STRING, ERR_R_MALLOC_FAILURE); | 415 | X509V3error(ERR_R_MALLOC_FAILURE); |
| 424 | return NULL; | 416 | return NULL; |
| 425 | } | 417 | } |
| 426 | q = tmp; | 418 | q = tmp; |
| @@ -443,8 +435,7 @@ string_to_hex(const char *str, long *len) | |||
| 443 | unsigned char *hexbuf, *q; | 435 | unsigned char *hexbuf, *q; |
| 444 | unsigned char ch, cl, *p; | 436 | unsigned char ch, cl, *p; |
| 445 | if (!str) { | 437 | if (!str) { |
| 446 | X509V3err(X509V3_F_STRING_TO_HEX, | 438 | X509V3error(X509V3_R_INVALID_NULL_ARGUMENT); |
| 447 | X509V3_R_INVALID_NULL_ARGUMENT); | ||
| 448 | return NULL; | 439 | return NULL; |
| 449 | } | 440 | } |
| 450 | if (!(hexbuf = malloc(strlen(str) >> 1))) | 441 | if (!(hexbuf = malloc(strlen(str) >> 1))) |
| @@ -455,8 +446,7 @@ string_to_hex(const char *str, long *len) | |||
| 455 | continue; | 446 | continue; |
| 456 | cl = *p++; | 447 | cl = *p++; |
| 457 | if (!cl) { | 448 | if (!cl) { |
| 458 | X509V3err(X509V3_F_STRING_TO_HEX, | 449 | X509V3error(X509V3_R_ODD_NUMBER_OF_DIGITS); |
| 459 | X509V3_R_ODD_NUMBER_OF_DIGITS); | ||
| 460 | free(hexbuf); | 450 | free(hexbuf); |
| 461 | return NULL; | 451 | return NULL; |
| 462 | } | 452 | } |
| @@ -487,12 +477,12 @@ string_to_hex(const char *str, long *len) | |||
| 487 | 477 | ||
| 488 | err: | 478 | err: |
| 489 | free(hexbuf); | 479 | free(hexbuf); |
| 490 | X509V3err(X509V3_F_STRING_TO_HEX, ERR_R_MALLOC_FAILURE); | 480 | X509V3error(ERR_R_MALLOC_FAILURE); |
| 491 | return NULL; | 481 | return NULL; |
| 492 | 482 | ||
| 493 | badhex: | 483 | badhex: |
| 494 | free(hexbuf); | 484 | free(hexbuf); |
| 495 | X509V3err(X509V3_F_STRING_TO_HEX, X509V3_R_ILLEGAL_HEX_DIGIT); | 485 | X509V3error(X509V3_R_ILLEGAL_HEX_DIGIT); |
| 496 | return NULL; | 486 | return NULL; |
| 497 | } | 487 | } |
| 498 | 488 | ||
