diff --git a/src/pk/asn1/der/utf8/der_encode_utf8_string.c b/src/pk/asn1/der/utf8/der_encode_utf8_string.c index ab7ab54..ca4bfce 100644 --- a/src/pk/asn1/der/utf8/der_encode_utf8_string.c +++ b/src/pk/asn1/der/utf8/der_encode_utf8_string.c @@ -87,7 +87,9 @@ int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, case 1: out[x++] = (unsigned char)in[y]; break; case 2: out[x++] = 0xC0 | ((in[y] >> 6) & 0x1F); out[x++] = 0x80 | (in[y] & 0x3F); break; case 3: out[x++] = 0xE0 | ((in[y] >> 12) & 0x0F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break; +#if !defined(__WCHAR_MAX__) && !defined(WCHAR_MAX) || __WCHAR_MAX__ > 0xFFFF || WCHAR_MAX > 0xFFFF case 4: out[x++] = 0xF0 | ((in[y] >> 18) & 0x07); out[x++] = 0x80 | ((in[y] >> 12) & 0x3F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break; +#endif } } diff --git a/src/pk/asn1/der/utf8/der_length_utf8_string.c b/src/pk/asn1/der/utf8/der_length_utf8_string.c index 7d0f60c..85eec06 100644 --- a/src/pk/asn1/der/utf8/der_length_utf8_string.c +++ b/src/pk/asn1/der/utf8/der_length_utf8_string.c @@ -27,7 +27,7 @@ unsigned long der_utf8_charsize(const wchar_t c) return 1; } else if (c <= 0x7FF) { return 2; -#if __WCHAR_MAX__ == 0xFFFF +#if __WCHAR_MAX__ == 0xFFFF || WCHAR_MAX == 0xFFFF } else { return 3; } @@ -48,10 +48,10 @@ unsigned long der_utf8_charsize(const wchar_t c) int der_utf8_valid_char(const wchar_t c) { LTC_UNUSED_PARAM(c); -#if !defined(__WCHAR_MAX__) || __WCHAR_MAX__ > 0xFFFF +#if !defined(__WCHAR_MAX__) && !defined(WCHAR_MAX) || __WCHAR_MAX__ > 0xFFFF || WCHAR_MAX > 0xFFFF if (c > 0x10FFFF) return 0; #endif -#if !defined(__WCHAR_MAX__) || __WCHAR_MAX__ != 0xFFFF && __WCHAR_MAX__ != 0xFFFFFFFF +#if !defined(__WCHAR_MAX__) && !defined(WCHAR_MAX) || __WCHAR_MAX__ != 0xFFFF && __WCHAR_MAX__ != 0xFFFFFFFF && WCHAR_MAX != 0xFFFF && WCHAR_MAX != 0xFFFFFFFF if (c < 0) return 0; #endif return 1;