diff options
author | beck <> | 2017-01-29 17:49:23 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:49:23 +0000 |
commit | 957b11334a7afb14537322f0e4795b2e368b3f59 (patch) | |
tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/asn1/a_mbstr.c | |
parent | df96e020e729c6c37a8c7fe311fdd1fe6a8718c5 (diff) | |
download | openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.gz openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.bz2 openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.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/asn1/a_mbstr.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_mbstr.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/lib/libcrypto/asn1/a_mbstr.c b/src/lib/libcrypto/asn1/a_mbstr.c index e715fe7348..b7cfba379a 100644 --- a/src/lib/libcrypto/asn1/a_mbstr.c +++ b/src/lib/libcrypto/asn1/a_mbstr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: a_mbstr.c,v 1.22 2015/07/16 02:18:58 miod Exp $ */ | 1 | /* $OpenBSD: a_mbstr.c,v 1.23 2017/01/29 17:49:22 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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -113,8 +113,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
113 | switch (inform) { | 113 | switch (inform) { |
114 | case MBSTRING_BMP: | 114 | case MBSTRING_BMP: |
115 | if (len & 1) { | 115 | if (len & 1) { |
116 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, | 116 | ASN1error(ASN1_R_INVALID_BMPSTRING_LENGTH); |
117 | ASN1_R_INVALID_BMPSTRING_LENGTH); | ||
118 | return -1; | 117 | return -1; |
119 | } | 118 | } |
120 | nchar = len >> 1; | 119 | nchar = len >> 1; |
@@ -122,8 +121,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
122 | 121 | ||
123 | case MBSTRING_UNIV: | 122 | case MBSTRING_UNIV: |
124 | if (len & 3) { | 123 | if (len & 3) { |
125 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, | 124 | ASN1error(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH); |
126 | ASN1_R_INVALID_UNIVERSALSTRING_LENGTH); | ||
127 | return -1; | 125 | return -1; |
128 | } | 126 | } |
129 | nchar = len >> 2; | 127 | nchar = len >> 2; |
@@ -134,8 +132,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
134 | /* This counts the characters and does utf8 syntax checking */ | 132 | /* This counts the characters and does utf8 syntax checking */ |
135 | ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar); | 133 | ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar); |
136 | if (ret < 0) { | 134 | if (ret < 0) { |
137 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, | 135 | ASN1error(ASN1_R_INVALID_UTF8STRING); |
138 | ASN1_R_INVALID_UTF8STRING); | ||
139 | return -1; | 136 | return -1; |
140 | } | 137 | } |
141 | break; | 138 | break; |
@@ -145,25 +142,25 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
145 | break; | 142 | break; |
146 | 143 | ||
147 | default: | 144 | default: |
148 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_UNKNOWN_FORMAT); | 145 | ASN1error(ASN1_R_UNKNOWN_FORMAT); |
149 | return -1; | 146 | return -1; |
150 | } | 147 | } |
151 | 148 | ||
152 | if ((minsize > 0) && (nchar < minsize)) { | 149 | if ((minsize > 0) && (nchar < minsize)) { |
153 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_SHORT); | 150 | ASN1error(ASN1_R_STRING_TOO_SHORT); |
154 | ERR_asprintf_error_data("minsize=%ld", minsize); | 151 | ERR_asprintf_error_data("minsize=%ld", minsize); |
155 | return -1; | 152 | return -1; |
156 | } | 153 | } |
157 | 154 | ||
158 | if ((maxsize > 0) && (nchar > maxsize)) { | 155 | if ((maxsize > 0) && (nchar > maxsize)) { |
159 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_STRING_TOO_LONG); | 156 | ASN1error(ASN1_R_STRING_TOO_LONG); |
160 | ERR_asprintf_error_data("maxsize=%ld", maxsize); | 157 | ERR_asprintf_error_data("maxsize=%ld", maxsize); |
161 | return -1; | 158 | return -1; |
162 | } | 159 | } |
163 | 160 | ||
164 | /* Now work out minimal type (if any) */ | 161 | /* Now work out minimal type (if any) */ |
165 | if (traverse_string(in, len, inform, type_str, &mask) < 0) { | 162 | if (traverse_string(in, len, inform, type_str, &mask) < 0) { |
166 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ASN1_R_ILLEGAL_CHARACTERS); | 163 | ASN1error(ASN1_R_ILLEGAL_CHARACTERS); |
167 | return -1; | 164 | return -1; |
168 | } | 165 | } |
169 | 166 | ||
@@ -201,8 +198,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
201 | free_out = 1; | 198 | free_out = 1; |
202 | dest = ASN1_STRING_type_new(str_type); | 199 | dest = ASN1_STRING_type_new(str_type); |
203 | if (!dest) { | 200 | if (!dest) { |
204 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, | 201 | ASN1error(ERR_R_MALLOC_FAILURE); |
205 | ERR_R_MALLOC_FAILURE); | ||
206 | return -1; | 202 | return -1; |
207 | } | 203 | } |
208 | *out = dest; | 204 | *out = dest; |
@@ -210,8 +206,7 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
210 | /* If both the same type just copy across */ | 206 | /* If both the same type just copy across */ |
211 | if (inform == outform) { | 207 | if (inform == outform) { |
212 | if (!ASN1_STRING_set(dest, in, len)) { | 208 | if (!ASN1_STRING_set(dest, in, len)) { |
213 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, | 209 | ASN1error(ERR_R_MALLOC_FAILURE); |
214 | ERR_R_MALLOC_FAILURE); | ||
215 | goto err; | 210 | goto err; |
216 | } | 211 | } |
217 | return str_type; | 212 | return str_type; |
@@ -237,15 +232,14 @@ ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, | |||
237 | case MBSTRING_UTF8: | 232 | case MBSTRING_UTF8: |
238 | outlen = 0; | 233 | outlen = 0; |
239 | if (traverse_string(in, len, inform, out_utf8, &outlen) < 0) { | 234 | if (traverse_string(in, len, inform, out_utf8, &outlen) < 0) { |
240 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, | 235 | ASN1error(ASN1_R_ILLEGAL_CHARACTERS); |
241 | ASN1_R_ILLEGAL_CHARACTERS); | ||
242 | goto err; | 236 | goto err; |
243 | } | 237 | } |
244 | cpyfunc = cpy_utf8; | 238 | cpyfunc = cpy_utf8; |
245 | break; | 239 | break; |
246 | } | 240 | } |
247 | if (!(p = malloc(outlen + 1))) { | 241 | if (!(p = malloc(outlen + 1))) { |
248 | ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE); | 242 | ASN1error(ERR_R_MALLOC_FAILURE); |
249 | goto err; | 243 | goto err; |
250 | } | 244 | } |
251 | dest->length = outlen; | 245 | dest->length = outlen; |