X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Frfc2047.c;h=6c461029b136d1f9e0ea6ab036bb85032612e9e6;hp=6eb56752117bca776ac7f19b6e49769bb7afd444;hb=1e1ddfac79fbcd052f199500a6493c7f79cb8462;hpb=9242a7e8cfa94bbc9dd7eca6bd651b569b871c4e diff --git a/src/src/rfc2047.c b/src/src/rfc2047.c index 6eb567521..6c461029b 100644 --- a/src/src/rfc2047.c +++ b/src/src/rfc2047.c @@ -2,7 +2,8 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2017 */ +/* Copyright (c) University of Cambridge 1995 - 2018 */ +/* Copyright (c) The Exim Maintainers 2020 */ /* See the file NOTICE for conditions of use and distribution. */ /* This file contains a function for decoding message header lines that may @@ -46,7 +47,7 @@ rfc2047_qpdecode(uschar *string, uschar **ptrptr) int len = 0; uschar *ptr; -ptr = *ptrptr = store_get(Ustrlen(string) + 1); /* No longer than this */ +ptr = *ptrptr = store_get(Ustrlen(string) + 1, is_tainted(string)); /* No longer than this */ while (*string != 0) { @@ -208,7 +209,7 @@ building the result as we go. The result may be longer than the input if it is translated into a multibyte code such as UTF-8. That's why we use the dynamic string building code. */ -yield = store_get(sizeof(gstring) + ++size); +yield = store_get(sizeof(gstring) + ++size, is_tainted(string)); yield->size = size; yield->ptr = 0; yield->s = US(yield + 1); @@ -222,6 +223,7 @@ while (mimeword) if (mimeword != string) yield = string_catn(yield, string, mimeword - string); +/*XXX that might have to convert an untainted string to a tainted one */ /* Do a charset translation if required. This is supported only on hosts that have the iconv() function. Translation errors set error, but carry on, @@ -232,17 +234,11 @@ while (mimeword) #if HAVE_ICONV *q1 = 0; - if (target != NULL && strcmpic(target, mimeword+2) != 0) - { - icd = iconv_open(CS target, CS(mimeword+2)); - - if (icd == (iconv_t)(-1)) - { + if (target && strcmpic(target, mimeword+2) != 0) + if ((icd = iconv_open(CS target, CS(mimeword+2))) == (iconv_t)-1) *error = string_sprintf("iconv_open(\"%s\", \"%s\") failed: %s%s", target, mimeword+2, strerror(errno), (errno == EINVAL)? " (maybe unsupported conversion)" : ""); - } - } *q1 = '?'; #endif @@ -300,11 +296,8 @@ while (mimeword) /* Deal with zero values; convert them if requested. */ if (zeroval != 0) - { - int i; - for (i = 0; i < tlen; i++) + for (int i = 0; i < tlen; i++) if (tptr[i] == 0) tptr[i] = zeroval; - } /* Add the new string onto the result */