From d403be92a436a45bd9be2e016cb250e7157dfeb3 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 12 Apr 2017 16:28:25 -0400 Subject: [PATCH] Ensure consumers set up include paths properly. In some cases, consumers may include a BoringSSL header without setting up include paths. This risks pulling in system OpenSSL headers instead. For almost every BoringSSL header, the first #include is base.h, which does not exist upstream, thus the mistake will be caught. The exception is base.h itself which naturally does not include itself. Have it include an empty is_boringssl.h header to catch this mistake. Change-Id: Ia96586ecc627ff46867d8af8b68138185866f074 Reviewed-on: https://boringssl-review.googlesource.com/14949 Reviewed-by: Adam Langley --- include/openssl/base.h | 4 ++++ include/openssl/is_boringssl.h | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 include/openssl/is_boringssl.h diff --git a/include/openssl/base.h b/include/openssl/base.h index a9d1ec58..d121b6fb 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -65,6 +65,10 @@ #include #endif +/* Include a BoringSSL-only header so consumers including this header without + * setting up include paths do not accidentally pick up the system + * opensslconf.h. */ +#include #include #if defined(BORINGSSL_PREFIX) diff --git a/include/openssl/is_boringssl.h b/include/openssl/is_boringssl.h new file mode 100644 index 00000000..def6e82b --- /dev/null +++ b/include/openssl/is_boringssl.h @@ -0,0 +1,16 @@ +/* Copyright (c) 2017, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +/* This header is provided in order to catch include path errors in consuming + * BoringSSL. */