diff options
| author | mrezai | 2016-05-03 23:59:14 +0430 |
|---|---|---|
| committer | mrezai | 2016-05-03 23:59:14 +0430 |
| commit | ab623c923d4e2c950342aec5da371cb92b1fbbc6 (patch) | |
| tree | 14edc317fa408ca610bd85e6a82468dd347865db /drivers/builtin_openssl2/crypto/x509/x509_obj.c | |
| parent | e0d27c55237d4f61910b1e72b744fc043e9b6bff (diff) | |
| download | godot-ab623c923d4e2c950342aec5da371cb92b1fbbc6.tar.gz godot-ab623c923d4e2c950342aec5da371cb92b1fbbc6.tar.zst godot-ab623c923d4e2c950342aec5da371cb92b1fbbc6.zip | |
Update OpenSSL to 1.0.2h
Diffstat (limited to 'drivers/builtin_openssl2/crypto/x509/x509_obj.c')
| -rw-r--r-- | drivers/builtin_openssl2/crypto/x509/x509_obj.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/builtin_openssl2/crypto/x509/x509_obj.c b/drivers/builtin_openssl2/crypto/x509/x509_obj.c index d317f3af2..3de3ac720 100644 --- a/drivers/builtin_openssl2/crypto/x509/x509_obj.c +++ b/drivers/builtin_openssl2/crypto/x509/x509_obj.c @@ -63,6 +63,13 @@ #include <openssl/x509.h> #include <openssl/buffer.h> +/* + * Limit to ensure we don't overflow: much greater than + * anything enountered in practice. + */ + +#define NAME_ONELINE_MAX (1024 * 1024) + char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) { X509_NAME_ENTRY *ne; @@ -86,6 +93,8 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) goto err; b->data[0] = '\0'; len = 200; + } else if (len == 0) { + return NULL; } if (a == NULL) { if (b) { @@ -110,6 +119,10 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) type = ne->value->type; num = ne->value->length; + if (num > NAME_ONELINE_MAX) { + X509err(X509_F_X509_NAME_ONELINE, X509_R_NAME_TOO_LONG); + goto end; + } q = ne->value->data; #ifdef CHARSET_EBCDIC if (type == V_ASN1_GENERALSTRING || @@ -117,8 +130,9 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) type == V_ASN1_PRINTABLESTRING || type == V_ASN1_TELETEXSTRING || type == V_ASN1_VISIBLESTRING || type == V_ASN1_IA5STRING) { - ascii2ebcdic(ebcdic_buf, q, (num > sizeof ebcdic_buf) - ? sizeof ebcdic_buf : num); + if (num > (int)sizeof(ebcdic_buf)) + num = sizeof(ebcdic_buf); + ascii2ebcdic(ebcdic_buf, q, num); q = ebcdic_buf; } #endif @@ -154,6 +168,10 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) lold = l; l += 1 + l1 + 1 + l2; + if (l > NAME_ONELINE_MAX) { + X509err(X509_F_X509_NAME_ONELINE, X509_R_NAME_TOO_LONG); + goto end; + } if (b != NULL) { if (!BUF_MEM_grow(b, l + 1)) goto err; @@ -206,7 +224,7 @@ char *X509_NAME_oneline(X509_NAME *a, char *buf, int len) return (p); err: X509err(X509_F_X509_NAME_ONELINE, ERR_R_MALLOC_FAILURE); - if (b != NULL) - BUF_MEM_free(b); + end: + BUF_MEM_free(b); return (NULL); } |
