diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_strnid.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c index 0585f7050b..0cc8dc8428 100644 --- a/src/lib/libcrypto/asn1/a_strnid.c +++ b/src/lib/libcrypto/asn1/a_strnid.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: a_strnid.c,v 1.21 2017/01/29 17:49:22 beck Exp $ */ | 1 | /* $OpenBSD: a_strnid.c,v 1.22 2021/12/11 22:34:36 schwarze 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 | */ |
| @@ -56,7 +56,6 @@ | |||
| 56 | * | 56 | * |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <ctype.h> | ||
| 60 | #include <stdio.h> | 59 | #include <stdio.h> |
| 61 | #include <string.h> | 60 | #include <string.h> |
| 62 | 61 | ||
| @@ -70,7 +69,8 @@ static int sk_table_cmp(const ASN1_STRING_TABLE * const *a, | |||
| 70 | const ASN1_STRING_TABLE * const *b); | 69 | const ASN1_STRING_TABLE * const *b); |
| 71 | 70 | ||
| 72 | 71 | ||
| 73 | /* This is the global mask for the mbstring functions: this is use to | 72 | /* |
| 73 | * This is the global mask for the mbstring functions: this is used to | ||
| 74 | * mask out certain types (such as BMPString and UTF8String) because | 74 | * mask out certain types (such as BMPString and UTF8String) because |
| 75 | * certain software (e.g. Netscape) has problems with them. | 75 | * certain software (e.g. Netscape) has problems with them. |
| 76 | */ | 76 | */ |
| @@ -89,7 +89,8 @@ ASN1_STRING_get_default_mask(void) | |||
| 89 | return global_mask; | 89 | return global_mask; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | /* This function sets the default to various "flavours" of configuration. | 92 | /* |
| 93 | * This function sets the default to various "flavours" of configuration | ||
| 93 | * based on an ASCII string. Currently this is: | 94 | * based on an ASCII string. Currently this is: |
| 94 | * MASK:XXXX : a numerical mask value. | 95 | * MASK:XXXX : a numerical mask value. |
| 95 | * nobmp : Don't use BMPStrings (just Printable, T61). | 96 | * nobmp : Don't use BMPStrings (just Printable, T61). |
| @@ -104,19 +105,19 @@ ASN1_STRING_set_default_mask_asc(const char *p) | |||
| 104 | unsigned long mask; | 105 | unsigned long mask; |
| 105 | char *end; | 106 | char *end; |
| 106 | 107 | ||
| 107 | if (!strncmp(p, "MASK:", 5)) { | 108 | if (strncmp(p, "MASK:", 5) == 0) { |
| 108 | if (!p[5]) | 109 | if (p[5] == '\0') |
| 109 | return 0; | 110 | return 0; |
| 110 | mask = strtoul(p + 5, &end, 0); | 111 | mask = strtoul(p + 5, &end, 0); |
| 111 | if (*end) | 112 | if (*end != '\0') |
| 112 | return 0; | 113 | return 0; |
| 113 | } else if (!strcmp(p, "nombstr")) | 114 | } else if (strcmp(p, "nombstr") == 0) |
| 114 | mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)); | 115 | mask = ~((unsigned long)(B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)); |
| 115 | else if (!strcmp(p, "pkix")) | 116 | else if (strcmp(p, "pkix") == 0) |
| 116 | mask = ~((unsigned long)B_ASN1_T61STRING); | 117 | mask = ~((unsigned long)B_ASN1_T61STRING); |
| 117 | else if (!strcmp(p, "utf8only")) | 118 | else if (strcmp(p, "utf8only") == 0) |
| 118 | mask = B_ASN1_UTF8STRING; | 119 | mask = B_ASN1_UTF8STRING; |
| 119 | else if (!strcmp(p, "default")) | 120 | else if (strcmp(p, "default") == 0) |
| 120 | mask = 0xFFFFFFFFL; | 121 | mask = 0xFFFFFFFFL; |
| 121 | else | 122 | else |
| 122 | return 0; | 123 | return 0; |
| @@ -124,7 +125,8 @@ ASN1_STRING_set_default_mask_asc(const char *p) | |||
| 124 | return 1; | 125 | return 1; |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | /* The following function generates an ASN1_STRING based on limits in a table. | 128 | /* |
| 129 | * The following function generates an ASN1_STRING based on limits in a table. | ||
| 128 | * Frequently the types and length of an ASN1_STRING are restricted by a | 130 | * Frequently the types and length of an ASN1_STRING are restricted by a |
| 129 | * corresponding OID. For example certificates and certificate requests. | 131 | * corresponding OID. For example certificates and certificate requests. |
| 130 | */ | 132 | */ |
| @@ -137,12 +139,13 @@ ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int inlen, | |||
| 137 | ASN1_STRING *str = NULL; | 139 | ASN1_STRING *str = NULL; |
| 138 | unsigned long mask; | 140 | unsigned long mask; |
| 139 | int ret; | 141 | int ret; |
| 140 | if (!out) | 142 | |
| 143 | if (out == NULL) | ||
| 141 | out = &str; | 144 | out = &str; |
| 142 | tbl = ASN1_STRING_TABLE_get(nid); | 145 | tbl = ASN1_STRING_TABLE_get(nid); |
| 143 | if (tbl) { | 146 | if (tbl != NULL) { |
| 144 | mask = tbl->mask; | 147 | mask = tbl->mask; |
| 145 | if (!(tbl->flags & STABLE_NO_MASK)) | 148 | if ((tbl->flags & STABLE_NO_MASK) == 0) |
| 146 | mask &= global_mask; | 149 | mask &= global_mask; |
| 147 | ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask, | 150 | ret = ASN1_mbstring_ncopy(out, in, inlen, inform, mask, |
| 148 | tbl->minsize, tbl->maxsize); | 151 | tbl->minsize, tbl->maxsize); |
| @@ -154,7 +157,8 @@ ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, int inlen, | |||
| 154 | return *out; | 157 | return *out; |
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | /* Now the tables and helper functions for the string table: | 160 | /* |
| 161 | * Now the tables and helper functions for the string table: | ||
| 158 | */ | 162 | */ |
| 159 | 163 | ||
| 160 | /* size limits: this stuff is taken straight from RFC3280 */ | 164 | /* size limits: this stuff is taken straight from RFC3280 */ |
| @@ -292,7 +296,7 @@ ASN1_STRING_TABLE_cleanup(void) | |||
| 292 | STACK_OF(ASN1_STRING_TABLE) *tmp; | 296 | STACK_OF(ASN1_STRING_TABLE) *tmp; |
| 293 | 297 | ||
| 294 | tmp = stable; | 298 | tmp = stable; |
| 295 | if (!tmp) | 299 | if (tmp == NULL) |
| 296 | return; | 300 | return; |
| 297 | stable = NULL; | 301 | stable = NULL; |
| 298 | sk_ASN1_STRING_TABLE_pop_free(tmp, st_free); | 302 | sk_ASN1_STRING_TABLE_pop_free(tmp, st_free); |
