X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fbase64.c;h=29f9c77b0d59746cc17c8963df92ddad4d841cf9;hb=b634f8eaf52aae84c311d7e306f38f3dc07ff1b0;hp=1d84c1e5c34116bbfdf9b137bd26ba19b1f3a1da;hpb=cf3cd306062a08969c41a1cdd32c6855f1abecf1;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/base64.c b/src/src/base64.c index 1d84c1e5c..29f9c77b0 100644 --- a/src/src/base64.c +++ b/src/src/base64.c @@ -5,7 +5,8 @@ /* Copyright (c) Tom Kistner 2004, 2015 */ /* License: GPL */ -/* 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. */ @@ -38,7 +39,7 @@ ssize_t mime_decode_base64(FILE * in, FILE * out, uschar * boundary) { uschar ibuf[MIME_MAX_LINE_LENGTH], obuf[MIME_MAX_LINE_LENGTH]; -uschar *ipos, *opos; +uschar *opos; ssize_t len, size = 0; int bytestate = 0; @@ -52,7 +53,7 @@ while (Ufgets(ibuf, MIME_MAX_LINE_LENGTH, in) != NULL) ) break; - for (ipos = ibuf ; *ipos != '\r' && *ipos != '\n' && *ipos != 0; ++ipos) + for (uschar * ipos = ibuf ; *ipos != '\r' && *ipos != '\n' && *ipos; ++ipos) if (*ipos == '=') /* skip padding */ ++bytestate; @@ -158,7 +159,7 @@ uschar *result; { int l = Ustrlen(code); - *ptr = result = store_get(1 + l/4 * 3 + l%4); + *ptr = result = store_get(1 + l/4 * 3 + l%4, is_tainted(code)); } /* Each cycle of the loop handles a quantum of 4 input bytes. For the last @@ -173,7 +174,7 @@ while ((x = *code++) != 0) while (isspace(y = *code++)) ; /* debug_printf("b64d: '%c'\n", y); */ - if (y == 0 || (y = dec64table[y]) == 255) + if (y > 127 || (y = dec64table[y]) == 255) return -1; *result++ = (x << 2) | (y >> 4); @@ -242,9 +243,9 @@ static uschar *enc64table = US"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; uschar * -b64encode(uschar *clear, int len) +b64encode_taint(const uschar * clear, int len, BOOL tainted) { -uschar *code = store_get(4*((len+2)/3) + 1); +uschar *code = store_get(4*((len+2)/3) + 1, tainted); uschar *p = code; while (len-- >0) @@ -283,6 +284,12 @@ while (len-- >0) return code; } +uschar * +b64encode(const uschar * clear, int len) +{ +return b64encode_taint(clear, len, is_tainted(clear)); +} + /* End of base64.c */ /* vi: sw ai sw=2