diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_strex.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_strex.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c index a07122ba47..c2dbb6f9a5 100644 --- a/src/lib/libcrypto/asn1/a_strex.c +++ b/src/lib/libcrypto/asn1/a_strex.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| 6 | * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. |
| 7 | * | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
| @@ -58,12 +58,12 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include "cryptlib.h" | ||
| 61 | #include <openssl/crypto.h> | 62 | #include <openssl/crypto.h> |
| 62 | #include <openssl/x509.h> | 63 | #include <openssl/x509.h> |
| 63 | #include <openssl/asn1.h> | 64 | #include <openssl/asn1.h> |
| 64 | 65 | ||
| 65 | #include "charmap.h" | 66 | #include "charmap.h" |
| 66 | #include "cryptlib.h" | ||
| 67 | 67 | ||
| 68 | /* ASN1_STRING_print_ex() and X509_NAME_print_ex(). | 68 | /* ASN1_STRING_print_ex() and X509_NAME_print_ex(). |
| 69 | * Enhanced string and name printing routines handling | 69 | * Enhanced string and name printing routines handling |
| @@ -170,7 +170,7 @@ static int do_buf(unsigned char *buf, int buflen, | |||
| 170 | q = buf + buflen; | 170 | q = buf + buflen; |
| 171 | outlen = 0; | 171 | outlen = 0; |
| 172 | while(p != q) { | 172 | while(p != q) { |
| 173 | if(p == buf) orflags = CHARTYPE_FIRST_ESC_2253; | 173 | if(p == buf && flags & ASN1_STRFLGS_ESC_2253) orflags = CHARTYPE_FIRST_ESC_2253; |
| 174 | else orflags = 0; | 174 | else orflags = 0; |
| 175 | switch(type & BUF_TYPE_WIDTH_MASK) { | 175 | switch(type & BUF_TYPE_WIDTH_MASK) { |
| 176 | case 4: | 176 | case 4: |
| @@ -194,8 +194,10 @@ static int do_buf(unsigned char *buf, int buflen, | |||
| 194 | if(i < 0) return -1; /* Invalid UTF8String */ | 194 | if(i < 0) return -1; /* Invalid UTF8String */ |
| 195 | p += i; | 195 | p += i; |
| 196 | break; | 196 | break; |
| 197 | default: | ||
| 198 | return -1; /* invalid width */ | ||
| 197 | } | 199 | } |
| 198 | if (p == q) orflags = CHARTYPE_LAST_ESC_2253; | 200 | if (p == q && flags & ASN1_STRFLGS_ESC_2253) orflags = CHARTYPE_LAST_ESC_2253; |
| 199 | if(type & BUF_TYPE_CONVUTF8) { | 201 | if(type & BUF_TYPE_CONVUTF8) { |
| 200 | unsigned char utfbuf[6]; | 202 | unsigned char utfbuf[6]; |
| 201 | int utflen; | 203 | int utflen; |
| @@ -223,7 +225,7 @@ static int do_buf(unsigned char *buf, int buflen, | |||
| 223 | 225 | ||
| 224 | static int do_hex_dump(char_io *io_ch, void *arg, unsigned char *buf, int buflen) | 226 | static int do_hex_dump(char_io *io_ch, void *arg, unsigned char *buf, int buflen) |
| 225 | { | 227 | { |
| 226 | const static char hexdig[] = "0123456789ABCDEF"; | 228 | static const char hexdig[] = "0123456789ABCDEF"; |
| 227 | unsigned char *p, *q; | 229 | unsigned char *p, *q; |
| 228 | char hextmp[2]; | 230 | char hextmp[2]; |
| 229 | if(arg) { | 231 | if(arg) { |
| @@ -279,7 +281,7 @@ static int do_dump(unsigned long lflags, char_io *io_ch, void *arg, ASN1_STRING | |||
| 279 | * otherwise it is the number of bytes per character | 281 | * otherwise it is the number of bytes per character |
| 280 | */ | 282 | */ |
| 281 | 283 | ||
| 282 | const static signed char tag2nbyte[] = { | 284 | static const signed char tag2nbyte[] = { |
| 283 | -1, -1, -1, -1, -1, /* 0-4 */ | 285 | -1, -1, -1, -1, -1, /* 0-4 */ |
| 284 | -1, -1, -1, -1, -1, /* 5-9 */ | 286 | -1, -1, -1, -1, -1, /* 5-9 */ |
| 285 | -1, -1, 0, -1, /* 10-13 */ | 287 | -1, -1, 0, -1, /* 10-13 */ |
| @@ -356,12 +358,13 @@ static int do_print_ex(char_io *io_ch, void *arg, unsigned long lflags, ASN1_STR | |||
| 356 | } | 358 | } |
| 357 | 359 | ||
| 358 | len = do_buf(str->data, str->length, type, flags, "es, io_ch, NULL); | 360 | len = do_buf(str->data, str->length, type, flags, "es, io_ch, NULL); |
| 359 | if(outlen < 0) return -1; | 361 | if(len < 0) return -1; |
| 360 | outlen += len; | 362 | outlen += len; |
| 361 | if(quotes) outlen += 2; | 363 | if(quotes) outlen += 2; |
| 362 | if(!arg) return outlen; | 364 | if(!arg) return outlen; |
| 363 | if(quotes && !io_ch(arg, "\"", 1)) return -1; | 365 | if(quotes && !io_ch(arg, "\"", 1)) return -1; |
| 364 | do_buf(str->data, str->length, type, flags, NULL, io_ch, arg); | 366 | if(do_buf(str->data, str->length, type, flags, NULL, io_ch, arg) < 0) |
| 367 | return -1; | ||
| 365 | if(quotes && !io_ch(arg, "\"", 1)) return -1; | 368 | if(quotes && !io_ch(arg, "\"", 1)) return -1; |
| 366 | return outlen; | 369 | return outlen; |
| 367 | } | 370 | } |
| @@ -513,7 +516,7 @@ int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags) | |||
| 513 | return do_name_ex(send_bio_chars, out, nm, indent, flags); | 516 | return do_name_ex(send_bio_chars, out, nm, indent, flags); |
| 514 | } | 517 | } |
| 515 | 518 | ||
| 516 | 519 | #ifndef OPENSSL_NO_FP_API | |
| 517 | int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) | 520 | int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags) |
| 518 | { | 521 | { |
| 519 | if(flags == XN_FLAG_COMPAT) | 522 | if(flags == XN_FLAG_COMPAT) |
| @@ -528,17 +531,19 @@ int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long fla | |||
| 528 | } | 531 | } |
| 529 | return do_name_ex(send_fp_chars, fp, nm, indent, flags); | 532 | return do_name_ex(send_fp_chars, fp, nm, indent, flags); |
| 530 | } | 533 | } |
| 534 | #endif | ||
| 531 | 535 | ||
| 532 | int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags) | 536 | int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags) |
| 533 | { | 537 | { |
| 534 | return do_print_ex(send_bio_chars, out, flags, str); | 538 | return do_print_ex(send_bio_chars, out, flags, str); |
| 535 | } | 539 | } |
| 536 | 540 | ||
| 537 | 541 | #ifndef OPENSSL_NO_FP_API | |
| 538 | int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags) | 542 | int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags) |
| 539 | { | 543 | { |
| 540 | return do_print_ex(send_fp_chars, fp, flags, str); | 544 | return do_print_ex(send_fp_chars, fp, flags, str); |
| 541 | } | 545 | } |
| 546 | #endif | ||
| 542 | 547 | ||
| 543 | /* Utility function: convert any string type to UTF8, returns number of bytes | 548 | /* Utility function: convert any string type to UTF8, returns number of bytes |
| 544 | * in output string or a negative error code | 549 | * in output string or a negative error code |
| @@ -553,12 +558,7 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in) | |||
| 553 | if((type < 0) || (type > 30)) return -1; | 558 | if((type < 0) || (type > 30)) return -1; |
| 554 | mbflag = tag2nbyte[type]; | 559 | mbflag = tag2nbyte[type]; |
| 555 | if(mbflag == -1) return -1; | 560 | if(mbflag == -1) return -1; |
| 556 | if (mbflag == 0) | 561 | mbflag |= MBSTRING_FLAG; |
| 557 | mbflag = MBSTRING_UTF8; | ||
| 558 | else if (mbflag == 4) | ||
| 559 | mbflag = MBSTRING_UNIV; | ||
| 560 | else | ||
| 561 | mbflag |= MBSTRING_FLAG; | ||
| 562 | stmp.data = NULL; | 562 | stmp.data = NULL; |
| 563 | ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); | 563 | ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); |
| 564 | if(ret < 0) return ret; | 564 | if(ret < 0) return ret; |
