diff options
author | guenther <> | 2014-05-20 01:21:52 +0000 |
---|---|---|
committer | guenther <> | 2014-05-20 01:21:52 +0000 |
commit | 3c12c2aea2c1cdfaab42054ed8643b2bd31e4fdd (patch) | |
tree | d009a3ee2d810a28ee368be1fe06aaab046f09b1 /src/lib/libcrypto/asn1/a_strex.c | |
parent | 71e22b3fafe9cd4167c81a927e41cd9a06077d02 (diff) | |
download | openbsd-3c12c2aea2c1cdfaab42054ed8643b2bd31e4fdd.tar.gz openbsd-3c12c2aea2c1cdfaab42054ed8643b2bd31e4fdd.tar.bz2 openbsd-3c12c2aea2c1cdfaab42054ed8643b2bd31e4fdd.zip |
Bring UTF8_{getc,putc} up-to-date: it's been a decade since 5- and 6-byte
encodings and encoding of surrogate pair code points were banned. Add
checks for those, both to those functions and to the code decoding the
BMP and UNIV encodings.
ok miod@
Diffstat (limited to 'src/lib/libcrypto/asn1/a_strex.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_strex.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c index 462a4059be..684e933c4f 100644 --- a/src/lib/libcrypto/asn1/a_strex.c +++ b/src/lib/libcrypto/asn1/a_strex.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <openssl/crypto.h> | 62 | #include <openssl/crypto.h> |
63 | #include <openssl/x509.h> | 63 | #include <openssl/x509.h> |
64 | #include <openssl/asn1.h> | 64 | #include <openssl/asn1.h> |
65 | #include "asn1_locl.h" | ||
65 | 66 | ||
66 | #include "charmap.h" | 67 | #include "charmap.h" |
67 | 68 | ||
@@ -215,11 +216,15 @@ do_buf(unsigned char *buf, int buflen, int type, unsigned char flags, | |||
215 | c |= ((unsigned long)*p++) << 16; | 216 | c |= ((unsigned long)*p++) << 16; |
216 | c |= ((unsigned long)*p++) << 8; | 217 | c |= ((unsigned long)*p++) << 8; |
217 | c |= *p++; | 218 | c |= *p++; |
219 | if (c > UNICODE_MAX || UNICODE_IS_SURROGATE(c)) | ||
220 | return -1; | ||
218 | break; | 221 | break; |
219 | 222 | ||
220 | case 2: | 223 | case 2: |
221 | c = ((unsigned long)*p++) << 8; | 224 | c = ((unsigned long)*p++) << 8; |
222 | c |= *p++; | 225 | c |= *p++; |
226 | if (UNICODE_IS_SURROGATE(c)) | ||
227 | return -1; | ||
223 | break; | 228 | break; |
224 | 229 | ||
225 | case 1: | 230 | case 1: |
@@ -240,7 +245,10 @@ do_buf(unsigned char *buf, int buflen, int type, unsigned char flags, | |||
240 | if (type & BUF_TYPE_CONVUTF8) { | 245 | if (type & BUF_TYPE_CONVUTF8) { |
241 | unsigned char utfbuf[6]; | 246 | unsigned char utfbuf[6]; |
242 | int utflen; | 247 | int utflen; |
248 | |||
243 | utflen = UTF8_putc(utfbuf, sizeof utfbuf, c); | 249 | utflen = UTF8_putc(utfbuf, sizeof utfbuf, c); |
250 | if (utflen < 0) | ||
251 | return -1; | ||
244 | for (i = 0; i < utflen; i++) { | 252 | for (i = 0; i < utflen; i++) { |
245 | /* We don't need to worry about setting orflags correctly | 253 | /* We don't need to worry about setting orflags correctly |
246 | * because if utflen==1 its value will be correct anyway | 254 | * because if utflen==1 its value will be correct anyway |