--- parser3/src/classes/math.C 2019/11/13 21:29:51 1.89 +++ parser3/src/classes/math.C 2019/11/15 11:11:13 1.93 @@ -10,6 +10,7 @@ #include "pa_vmethod_frame.h" #include "pa_common.h" +#include "pa_base64.h" #include "pa_vint.h" #include "pa_vmath.h" #include "pa_vfile.h" @@ -22,7 +23,7 @@ extern "C" char *crypt(const char* , const char* ); #endif -volatile const char * IDENT_MATH_C="$Id: math.C,v 1.89 2019/11/13 21:29:51 moko Exp $"; +volatile const char * IDENT_MATH_C="$Id: math.C,v 1.93 2019/11/15 11:11:13 moko Exp $"; // defines @@ -634,9 +635,9 @@ static void _convert(Request& r, MethodP return; } - // core + // core, using log since log2 is not present in FreeBSD < 8.X - Array remainders(round(data.length * log2(base_from) / log2(base_to)) + 1); + Array remainders((size_t)round(data.length * log(base_from) / log(base_to)) + 1); do { int carry = 0; @@ -668,7 +669,13 @@ static void _convert(Request& r, MethodP result_file->set(true /*tainted*/, 0 /*binary*/, result_str, result_length, 0, 0, &r); r.write(*result_file); } else { - r.write(*new String(result_str, String::L_TAINTED)); // note: there can be '\0' inside + if(memchr(result_str, 0, result_length)) + throw Exception(PARSER_RUNTIME, 0, "Invalid \\x00 character found while converting to string. Convert to file instead."); + + fix_line_breaks(result_str, result_length); + + if(result_length) + r.write(*new String(result_str, String::L_TAINTED)); } }