Changes debuglogs schema to avoid unecessary str allocation

This commit is contained in:
Felipe Zimmerle
2018-10-19 16:56:33 -03:00
parent 23e0d35d2d
commit ef7f65db90
57 changed files with 1100 additions and 1374 deletions

View File

@@ -126,58 +126,48 @@ bool ValidateUtf8Encoding::evaluate(Transaction *transaction, Rule *rule,
switch (rc) {
case UNICODE_ERROR_CHARACTERS_MISSING :
if (transaction) {
#ifndef NO_LOGS
transaction->debug(8, "Invalid UTF-8 encoding: "
ms_dbg_a(transaction, 8, "Invalid UTF-8 encoding: "
"not enough bytes in character "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
break;
case UNICODE_ERROR_INVALID_ENCODING :
if (transaction) {
#ifndef NO_LOGS
transaction->debug(8, "Invalid UTF-8 encoding: "
ms_dbg_a(transaction, 8, "Invalid UTF-8 encoding: "
"invalid byte value in character "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
logOffset(ruleMessage, i, str.size());
}
return true;
break;
case UNICODE_ERROR_OVERLONG_CHARACTER :
if (transaction) {
#ifndef NO_LOGS
transaction->debug(8, "Invalid UTF-8 encoding: "
ms_dbg_a(transaction, 8, "Invalid UTF-8 encoding: "
"overlong character detected "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
logOffset(ruleMessage, i, str.size());
}
return true;
break;
case UNICODE_ERROR_RESTRICTED_CHARACTER :
if (transaction) {
#ifndef NO_LOGS
transaction->debug(8, "Invalid UTF-8 encoding: "
ms_dbg_a(transaction, 8, "Invalid UTF-8 encoding: "
"use of restricted character "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
logOffset(ruleMessage, i, str.size());
}
return true;
break;
case UNICODE_ERROR_DECODING_ERROR :
if (transaction) {
#ifndef NO_LOGS
transaction->debug(8, "Error validating UTF-8 decoding "
ms_dbg_a(transaction, 8, "Error validating UTF-8 decoding "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
logOffset(ruleMessage, i, str.size());
}
return true;
@@ -186,11 +176,9 @@ bool ValidateUtf8Encoding::evaluate(Transaction *transaction, Rule *rule,
if (rc <= 0) {
if (transaction) {
#ifndef NO_LOGS
transaction->debug(8, "Internal error during UTF-8 validation "
ms_dbg_a(transaction, 8, "Internal error during UTF-8 validation "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
logOffset(ruleMessage, i, str.size());
}
return true;