summaryrefslogtreecommitdiff
path: root/crypto/conf
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2021-01-13 08:51:39 +0100
committerDmitry Belyavskiy <beldmit@gmail.com>2021-01-14 11:20:10 +0100
commit4369a882a565c42673b28c586a5c46a8bca98d17 (patch)
tree2dce40f95d35651dc925fae5e7e191b185038585 /crypto/conf
parent5eb24fbd1c3e0d130ba7f81f1ccf457a2b9d75ad (diff)
downloadopenssl-new-4369a882a565c42673b28c586a5c46a8bca98d17.tar.gz
Skip BOM when reading the config file
Fixes #13840 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13857)
Diffstat (limited to 'crypto/conf')
-rw-r--r--crypto/conf/conf_def.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index a7f5677a26..99063eaf68 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -194,6 +194,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
BUF_MEM *buff = NULL;
char *s, *p, *end;
int again;
+ int first_call = 1;
long eline = 0;
char btmp[DECIMAL_SIZE(eline) + 1];
CONF_VALUE *v = NULL, *tv;
@@ -243,6 +244,19 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
goto err;
p[CONFBUFSIZE - 1] = '\0';
ii = i = strlen(p);
+ if (first_call) {
+ /* Other BOMs imply unsupported multibyte encoding,
+ * so don't strip them and let the error raise */
+ const unsigned char utf8_bom[3] = {0xEF, 0xBB, 0xBF};
+
+ if (i >= 3 && memcmp(p, utf8_bom, 3) == 0) {
+ memmove(p, p + 3, i - 3);
+ p[i - 3] = 0;
+ i -= 3;
+ ii -= 3;
+ }
+ first_call = 0;
+ }
if (i == 0 && !again) {
/* the currently processed BIO is NULL or at EOF */
BIO *parent;