From 9842b92bd1534c0fb6053213b1ac9f1cde1a117c Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 21 Feb 2024 13:50:51 +0100 Subject: [PATCH 1/4] src/actions/transformations/hex_decode.cc: reduce the scope of variable in a for () loop In general, it is always preferable to reduce the scope of a variable in a for loop --- src/actions/transformations/hex_decode.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/transformations/hex_decode.cc b/src/actions/transformations/hex_decode.cc index e626bc5f..1525377c 100644 --- a/src/actions/transformations/hex_decode.cc +++ b/src/actions/transformations/hex_decode.cc @@ -58,13 +58,13 @@ std::string HexDecode::evaluate(const std::string &value, int HexDecode::inplace(unsigned char *data, int len) { unsigned char *d = data; - int i, count = 0; + int count = 0; if ((data == NULL) || (len == 0)) { return 0; } - for (i = 0; i <= len - 2; i += 2) { + for (int i = 0;i <= len - 2;i += 2) { *d++ = utils::string::x2c(&data[i]); count++; } From b23abf440adb6ede034140d0f40962526050f8fc Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 21 Feb 2024 13:50:51 +0100 Subject: [PATCH 2/4] src/operators/verify_cc.cc: reduce the scope of variable in a for () loop In general, it is always preferable to reduce the scope of a variable in a for loop --- src/operators/verify_cc.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/operators/verify_cc.cc b/src/operators/verify_cc.cc index ee39902d..8a36bb7e 100644 --- a/src/operators/verify_cc.cc +++ b/src/operators/verify_cc.cc @@ -59,7 +59,6 @@ int VerifyCC::luhnVerify(const char *ccnumber, int len) { int sum[2] = { 0, 0 }; int odd = 0; int digits = 0; - int i; /* Weighted lookup table which is just a precalculated (i = index): * i*2 + (( (i*2) > 9 ) ? -9 : 0) @@ -71,7 +70,7 @@ int VerifyCC::luhnVerify(const char *ccnumber, int len) { /* Add up only digits (weighted digits via lookup table) * for both odd and even CC numbers to avoid 2 passes. */ - for (i = 0; i < len; i++) { + for (int i = 0;i < len;i++) { if (ccnumber[i] >= (0 + 48) && ccnumber[i] <= (9 + 48)) { sum[0] += (!odd ? wtable[ccnumber[i] - '0'] : (ccnumber[i] - '0')); sum[1] += (odd ? wtable[ccnumber[i] - '0'] : (ccnumber[i] - '0')); From 7fed599fdb47503037b2c031a1e2c3ff83b4b65c Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 21 Feb 2024 13:50:51 +0100 Subject: [PATCH 3/4] src/request_body_processor/multipart.cc: reduce the scope of variable in a for () loop In general, it is always preferable to reduce the scope of a variable in a for loop --- src/request_body_processor/multipart.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/request_body_processor/multipart.cc b/src/request_body_processor/multipart.cc index 78dc5d9c..691a6fd3 100644 --- a/src/request_body_processor/multipart.cc +++ b/src/request_body_processor/multipart.cc @@ -231,7 +231,7 @@ int Multipart::boundary_characters_valid(const char *boundary) { void Multipart::validate_quotes(const char *data, char quote) { - int i, len; + int len; if (data == NULL) return; @@ -244,7 +244,7 @@ void Multipart::validate_quotes(const char *data, char quote) { len = strlen(data); - for (i = 0; i < len; i++) { + for (int i = 0;i < len;i++) { if (data[i] == '\'') { ms_dbg_a(m_transaction, 9, "Multipart: Invalid quoting detected: " \ From 2daebc090f271fe2e3fda3247748c7269e0d4190 Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 21 Feb 2024 13:50:51 +0100 Subject: [PATCH 4/4] src/utils/acmp.cc: reduce the scope of variable in a for () loop In general, it is always preferable to reduce the scope of a variable in a for loop --- src/utils/acmp.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/acmp.cc b/src/utils/acmp.cc index 2bfe7acb..708ce3a2 100644 --- a/src/utils/acmp.cc +++ b/src/utils/acmp.cc @@ -190,10 +190,9 @@ static size_t acmp_strlen(ACMP *parser, const char *str) { * len - length of input string */ static void acmp_strtoucs(ACMP *parser, const char *str, long *ucs_chars, int len) { - int i; const char *c = str; - for (i = 0; i < len; i++) { + for (int i = 0;i < len;i++) { *(ucs_chars++) = *(c++); } }