diff --git a/examples/multiprocess_c/multi.c b/examples/multiprocess_c/multi.c index 570f544b..1a0af821 100644 --- a/examples/multiprocess_c/multi.c +++ b/examples/multiprocess_c/multi.c @@ -42,11 +42,14 @@ void process_special_request (int j) { msc_process_uri(transaction, "http://www.modsecurity.org/test?foo=herewego", "GET", "1.1"); - msc_add_request_header(transaction, "User-Agent", - "Basic ModSecurity example"); + msc_add_request_header(transaction, + (const unsigned char *) "User-Agent", + (const unsigned char *) "Basic ModSecurity example"); msc_process_request_headers(transaction); msc_process_request_body(transaction); - msc_add_response_header(transaction, "Content-type", "text/html"); + msc_add_response_header(transaction, + (const unsigned char *) "Content-type", + (const unsigned char *) "text/html"); msc_process_response_headers(transaction, 200, "HTTP 1.0"); msc_process_response_body(transaction); msc_process_logging(transaction); @@ -70,11 +73,14 @@ void process_request (int j) { msc_process_uri(transaction, "http://www.modsecurity.org/test?key1=value1&key2=value2&key3=value3", "GET", "1.1"); - msc_add_request_header(transaction, "User-Agent", - "Basic ModSecurity example"); + msc_add_request_header(transaction, + (const unsigned char *) "User-Agent", + (const unsigned char *) "Basic ModSecurity example"); msc_process_request_headers(transaction); msc_process_request_body(transaction); - msc_add_response_header(transaction, "Content-type", "text/html"); + msc_add_response_header(transaction, + (const unsigned char *) "Content-type", + (const unsigned char *) "text/html"); msc_process_response_headers(transaction, 200, "HTTP 1.0"); msc_process_response_body(transaction); msc_process_logging(transaction); diff --git a/examples/reading_logs_via_rule_message/simple_request.cc b/examples/reading_logs_via_rule_message/simple_request.cc index da60d8da..51d2fd63 100644 --- a/examples/reading_logs_via_rule_message/simple_request.cc +++ b/examples/reading_logs_via_rule_message/simple_request.cc @@ -29,8 +29,8 @@ int main(int argc, char **argv) { return -1; } - *(argv++); - std::string rules(*argv); + char *rule = *(argv++); + std::string rules(rule); ReadingLogsViaRuleMessage rlvrm(request_header, request_uri, request_body, response_headers, response_body, ip, rules); rlvrm.process(); diff --git a/examples/using_bodies_in_chunks/simple_request.cc b/examples/using_bodies_in_chunks/simple_request.cc index cca09010..9157e2c8 100644 --- a/examples/using_bodies_in_chunks/simple_request.cc +++ b/examples/using_bodies_in_chunks/simple_request.cc @@ -133,9 +133,8 @@ int main(int argc, char **argv) { std::cout << std::endl << std::endl; return -1; } - *(argv++); - - std::string rules_arg(*argv); + char *rule = *(argv++); + std::string rules_arg(rule); /** * ModSecurity initial setup diff --git a/src/actions/tag.cc b/src/actions/tag.cc index a880d483..e64fa6c8 100644 --- a/src/actions/tag.cc +++ b/src/actions/tag.cc @@ -25,7 +25,7 @@ */ #include "modsecurity/rules_set.h" - +#ifdef MSC_DOCUMENTATION /** * Description: Assigns a tag (category) to a rule or a chain. * @@ -46,7 +46,7 @@ * * */ - +#endif namespace modsecurity { namespace actions { diff --git a/src/actions/transformations/remove_whitespace.cc b/src/actions/transformations/remove_whitespace.cc index 3e665057..6bca2623 100644 --- a/src/actions/transformations/remove_whitespace.cc +++ b/src/actions/transformations/remove_whitespace.cc @@ -34,11 +34,12 @@ void RemoveWhitespace::execute(const Transaction *t, ModSecString &out) noexcept { out = in; int64_t i = 0; + char nonBreakingSpaces = 0xa0; // loop through all the chars while (i < out.size()) { // remove whitespaces and non breaking spaces (NBSP) - if (isspace(out[i]) || (out[i] == NBSP)) { + if (isspace(out[i]) || (out[i] == nonBreakingSpaces)) { out.erase(i, 1); } else { /* if the space is not a whitespace char, increment counter diff --git a/src/actions/transformations/trim.cc b/src/actions/transformations/trim.cc index 983c74a8..cee61419 100644 --- a/src/actions/transformations/trim.cc +++ b/src/actions/transformations/trim.cc @@ -29,14 +29,22 @@ namespace transformations { void Trim::ltrim(ModSecString *s) { - s->erase(s->begin(), std::find_if(s->begin(), s->end(), - std::not1(std::ptr_fun(std::isspace)))); + s->erase( + s->begin(), + std::find_if(s->begin(), s->end(), [](unsigned char c) { + return !std::isspace(c); + }) + ); } void Trim::rtrim(ModSecString *s) { - s->erase(std::find_if(s->rbegin(), s->rend(), - std::not1(std::ptr_fun(std::isspace))).base(), s->end()); + s->erase( + std::find_if(s->rbegin(), s->rend(), [](unsigned char c) { + return !std::isspace(c); + }).base(), + s->end() + ); } diff --git a/src/transaction.cc b/src/transaction.cc index 3927fd0a..45a27d5e 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -1325,14 +1325,13 @@ int Transaction::appendResponseBody(const unsigned char *buf, size_t len) { * contents of the response body, otherwise there is no need to call this * method. * + * WARN: This is a skeleton that it is not in use yet. + * * @return It returns a buffer (const char *) - * @retval >0 body was update and available. - * @retval NULL Nothing was updated. * */ const char *Transaction::getResponseBody() const { - // int there_is_update = this->rules->loadResponseBodyFromJS(this); - return this->m_responseBody.str().c_str(); + return strdup(this->m_responseBody.str().c_str()); } diff --git a/src/utils/msc_tree.cc b/src/utils/msc_tree.cc index 24812242..815887b6 100644 --- a/src/utils/msc_tree.cc +++ b/src/utils/msc_tree.cc @@ -290,7 +290,7 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree unsigned char *buffer = NULL; unsigned char bitlen = 0; int bit_validation = 0, test_bit = 0; - int i = 0; + size_t i = 0; unsigned int x, y; TreeNode *node = NULL, *new_node = NULL; TreeNode *parent = NULL, *i_node = NULL;