diff options
author | Richard Levitte <levitte@openssl.org> | 2021-01-26 06:48:11 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-01-27 12:06:29 +0100 |
commit | eeb09f1bd7754e85e832853f46a726c761c93df1 (patch) | |
tree | 4b3dd5083033b6d07a7bb9b15e837081ff7590ba /crypto/params_from_text.c | |
parent | TLS client: allow cert verify callback return -1 for SSL_ERROR_WANT_RETRY_VERIFY (diff) | |
download | openssl-eeb09f1bd7754e85e832853f46a726c761c93df1.tar.xz openssl-eeb09f1bd7754e85e832853f46a726c761c93df1.zip |
Fix OSSL_PARAM_allocate_from_text() for EBCDIC
OSSL_PARAM_allocate_from_text() converted text values to UTF-8
OSSL_PARAMs with a simple strncpy(). However, if the text is EBCDIC,
that won't become UTF-8. Therefore, it's made to convert from EBCDIC
to ASCII on platforms where the native character encoding is the
former.
One might argue that the conversion should be the responsibility of
the application. However, this is a helper function, and the calling
application can't easily know what sort of OSSL_PARAM the input values
are going to be used for.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13961)
Diffstat (limited to 'crypto/params_from_text.c')
-rw-r--r-- | crypto/params_from_text.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/params_from_text.c b/crypto/params_from_text.c index d458d31b2e..24d96108d0 100644 --- a/crypto/params_from_text.c +++ b/crypto/params_from_text.c @@ -9,6 +9,7 @@ */ #include <string.h> +#include <openssl/ebcdic.h> #include <openssl/err.h> #include <openssl/params.h> @@ -139,7 +140,11 @@ static int construct_from_text(OSSL_PARAM *to, const OSSL_PARAM *paramdef, } break; case OSSL_PARAM_UTF8_STRING: +#ifdef CHARSET_EBCDIC + ebcdic2ascii(buf, value, buf_n); +#else strncpy(buf, value, buf_n); +#endif break; case OSSL_PARAM_OCTET_STRING: if (ishex) { |