diff options
author | Brian Smith <brian@briansmith.org> | 2016-01-18 11:21:42 +0300 |
---|---|---|
committer | David Benjamin <davidben@google.com> | 2016-03-26 00:39:52 +0300 |
commit | dc6c1b83819cb3788c60dd669241adc6752a4604 (patch) | |
tree | 79b80908936110ffebe36f6adabba913aebe8e04 /crypto/x509 | |
parent | db50299b247bb7eab4df8c8fdd82fc727e8f67c8 (diff) |
Fix build when using Visual Studio 2015 Update 1.
Many of the compatibility issues are described at
https://msdn.microsoft.com/en-us/library/mt612856.aspx. The macros
that suppressed warnings on a per-function basis no longer work in
Update 1, so replace them with #pragmas. Update 1 warns when |size_t|
arguments to |printf| are casted, so stop doing that casting.
Unfortunately, this requires an ugly hack to continue working in
MSVC 2013 as MSVC 2013 doesn't support "%zu". Finally, Update 1 has new
warnings, some of which need to be suppressed.
---
Updated by davidben to give up on suppressing warnings in crypto/x509 and
crypto/x509v3 as those directories aren't changed much from upstream. In each
of these cases, upstream opted just blindly initialize the variable, so do the
same. Also switch C4265 to level 4, per Microsoft's recommendation and work
around a bug in limits.h that happens to get fixed by Google include order
style.
(limits.h is sensitive to whether corecrt.h, pulled in by stddef.h and some
other headers, is included before it. The reason it affected just one file is
we often put the file's header first, which means base.h is pulling in
stddef.h. Relying on this is ugly, but it's no worse than what everything else
is doing and this doesn't seem worth making something as tame as limits.h so
messy to use.)
Change-Id: I02d1f935356899f424d3525d03eca401bfa3e6cd
Reviewed-on: https://boringssl-review.googlesource.com/7480
Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/asn1_gen.c | 3 | ||||
-rw-r--r-- | crypto/x509/pkcs7_test.c | 16 | ||||
-rw-r--r-- | crypto/x509/x509_vfy.c | 3 | ||||
-rw-r--r-- | crypto/x509/x_pubkey.c | 3 |
4 files changed, 14 insertions, 11 deletions
diff --git a/crypto/x509/asn1_gen.c b/crypto/x509/asn1_gen.c index 0660840f..03a0ab9f 100644 --- a/crypto/x509/asn1_gen.c +++ b/crypto/x509/asn1_gen.c @@ -142,7 +142,6 @@ ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf) } ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) - OPENSSL_SUPPRESS_POTENTIALLY_UNINITIALIZED_WARNINGS { ASN1_TYPE *ret; tag_exp_arg asn1_tags; @@ -155,7 +154,7 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) unsigned char *p; const unsigned char *cp; int cpy_len; - long hdr_len; + long hdr_len = 0; int hdr_constructed = 0, hdr_tag, hdr_class; int r; diff --git a/crypto/x509/pkcs7_test.c b/crypto/x509/pkcs7_test.c index 7e763226..2dfeb5ed 100644 --- a/crypto/x509/pkcs7_test.c +++ b/crypto/x509/pkcs7_test.c @@ -22,6 +22,8 @@ #include <openssl/stack.h> #include <openssl/x509.h> +#include "../test/test_util.h" + /* kPKCS7NSS contains the certificate chain of mail.google.com, as saved by NSS * using the Chrome UI. */ @@ -504,7 +506,7 @@ static int test_cert_reparse(const uint8_t *der_bytes, size_t der_len) { X509 *b = sk_X509_value(certs2, i); if (X509_cmp(a, b) != 0) { - fprintf(stderr, "Certificate %u differs.\n", (unsigned) i); + fprintf(stderr, "Certificate %" OPENSSL_PR_SIZE_T " differs.\n", i); return 0; } } @@ -568,7 +570,7 @@ static int test_crl_reparse(const uint8_t *der_bytes, size_t der_len) { X509_CRL *b = sk_X509_CRL_value(crls2, i); if (X509_CRL_cmp(a, b) != 0) { - fprintf(stderr, "CRL %u differs.\n", (unsigned) i); + fprintf(stderr, "CRL %" OPENSSL_PR_SIZE_T " differs.\n", i); return 0; } } @@ -606,8 +608,9 @@ static int test_pem_certs(const char *pem) { if (sk_X509_num(certs) != 1) { fprintf(stderr, - "Bad number of certificates from PKCS7_get_PEM_certificates: %u\n", - (unsigned)sk_X509_num(certs)); + "Bad number of certificates from PKCS7_get_PEM_certificates: " + "%" OPENSSL_PR_SIZE_T "\n", + sk_X509_num(certs)); return 0; } @@ -628,8 +631,9 @@ static int test_pem_crls(const char *pem) { if (sk_X509_CRL_num(crls) != 1) { fprintf(stderr, - "Bad number of CRLs from PKCS7_get_PEM_CRLs: %u\n", - (unsigned)sk_X509_CRL_num(crls)); + "Bad number of CRLs from PKCS7_get_PEM_CRLs: %" OPENSSL_PR_SIZE_T + "\n", + sk_X509_CRL_num(crls)); return 0; } diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index e7f2103f..2ed2f03e 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -844,11 +844,10 @@ static int check_revocation(X509_STORE_CTX *ctx) } static int check_cert(X509_STORE_CTX *ctx) - OPENSSL_SUPPRESS_POTENTIALLY_UNINITIALIZED_WARNINGS { X509_CRL *crl = NULL, *dcrl = NULL; X509 *x; - int ok, cnum; + int ok = 0, cnum; unsigned int last_reasons; cnum = ctx->error_depth; x = sk_X509_value(ctx->chain, cnum); diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index 47f256c7..1549195e 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -54,6 +54,8 @@ * copied and put under another distribution licence * [including the GNU Public Licence.] */ +#include <openssl/x509.h> + #include <limits.h> #include <openssl/asn1.h> @@ -64,7 +66,6 @@ #include <openssl/mem.h> #include <openssl/obj.h> #include <openssl/thread.h> -#include <openssl/x509.h> #include "../internal.h" |