From 27840e0d43ce342ec6838d4f6d2f3e9324079047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 5 Oct 2015 12:16:06 +0100 Subject: [PATCH 1/4] Fix compile error in net.c with musl libc fixes #278 --- ChangeLog | 6 ++++++ library/net.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6f8181b5e..05450f660 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ PolarSSL ChangeLog += Version 1.2.17 released 2015-10-xx + +Bugfix + * Fix compile error in net.c with musl libc. Found and patch provided by + zhasha (#278). + = Version 1.2.16 released 2015-09-17 Security diff --git a/library/net.c b/library/net.c index 0e5edc01e..2685d6a04 100644 --- a/library/net.c +++ b/library/net.c @@ -268,7 +268,7 @@ int net_accept( int bind_fd, int *client_fd, void *client_ip ) struct sockaddr_in client_addr; #if defined(__socklen_t_defined) || defined(_SOCKLEN_T) || \ - defined(_SOCKLEN_T_DECLARED) + defined(_SOCKLEN_T_DECLARED) || defined(__DEFINED_socklen_t) socklen_t n = (socklen_t) sizeof( client_addr ); #else int n = (int) sizeof( client_addr ); From 021a11500f2d7740efbe04b313e4cecd739036ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 5 Oct 2015 12:12:39 +0100 Subject: [PATCH 2/4] Add missing warning in doc Found by Nicholas Wilson fixes #288 --- include/polarssl/config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/polarssl/config.h b/include/polarssl/config.h index 3a18f8a26..b7d8b6b26 100644 --- a/include/polarssl/config.h +++ b/include/polarssl/config.h @@ -331,8 +331,9 @@ * If set, the X509 parser will not break-off when parsing an X509 certificate * and encountering an unknown critical extension. * - * Uncomment to prevent an error. + * \warning Depending on your PKI use, enabling this can be a security risk! * + * Uncomment to prevent an error. #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION */ From 0123405f323447148e7f79c6c7295696740ba100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 5 Oct 2015 11:40:01 +0100 Subject: [PATCH 3/4] Fix macroization of inline in C++ When compiling as C++, MSVC complains about our macroization of a keyword. Stop doing that as we know inline is always available in C++ --- ChangeLog | 1 + include/polarssl/cipher.h | 6 ++---- include/polarssl/md.h | 9 +++------ include/polarssl/pkcs11.h | 6 ++---- include/polarssl/ssl.h | 9 +++------ 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05450f660..6b29dc185 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ PolarSSL ChangeLog Bugfix * Fix compile error in net.c with musl libc. Found and patch provided by zhasha (#278). + * Fix macroization of 'inline' keywork when building as C++. (#279) = Version 1.2.16 released 2015-09-17 diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h index e78f8d1a4..006b1040e 100644 --- a/include/polarssl/cipher.h +++ b/include/polarssl/cipher.h @@ -29,10 +29,8 @@ #include -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ diff --git a/include/polarssl/md.h b/include/polarssl/md.h index e94f9be3a..ae38aadba 100644 --- a/include/polarssl/md.h +++ b/include/polarssl/md.h @@ -28,13 +28,10 @@ #include -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */ #define POLARSSL_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */ diff --git a/include/polarssl/pkcs11.h b/include/polarssl/pkcs11.h index aefdbf266..5fd952d92 100644 --- a/include/polarssl/pkcs11.h +++ b/include/polarssl/pkcs11.h @@ -34,10 +34,8 @@ #include -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline #endif /* __ARMCC_VERSION */ #endif /*_MSC_VER */ diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h index e31b77629..b4796a163 100644 --- a/include/polarssl/ssl.h +++ b/include/polarssl/ssl.h @@ -43,13 +43,10 @@ #include "zlib.h" #endif -#if defined(_MSC_VER) && !defined(inline) -#define inline _inline -#else -#if defined(__ARMCC_VERSION) && !defined(inline) +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif /* * SSL Error codes From cfd1ba9f7ca45159ef209e0ce981160cf18d8cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 5 Oct 2015 14:57:01 +0100 Subject: [PATCH 4/4] Fix spurious #endif from previous cherry-pick --- include/polarssl/cipher.h | 3 +-- include/polarssl/pkcs11.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h index 006b1040e..d50cb74b8 100644 --- a/include/polarssl/cipher.h +++ b/include/polarssl/cipher.h @@ -32,8 +32,7 @@ #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif #define POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */ #define POLARSSL_ERR_CIPHER_BAD_INPUT_DATA -0x6100 /**< Bad input parameters to function. */ diff --git a/include/polarssl/pkcs11.h b/include/polarssl/pkcs11.h index 5fd952d92..3b07c8497 100644 --- a/include/polarssl/pkcs11.h +++ b/include/polarssl/pkcs11.h @@ -37,8 +37,7 @@ #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline -#endif /* __ARMCC_VERSION */ -#endif /*_MSC_VER */ +#endif /** * Context for PKCS #11 private keys.