mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-19 02:40:35 +03:00
Cosmetic changes: applies changes suggested by static analysis
This commit is contained in:
@@ -100,9 +100,8 @@ int HtmlEntityDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
if (j > k) { /* Do we have at least one digit? */
|
||||
/* Decode the entity. */
|
||||
char *x = NULL;
|
||||
x = reinterpret_cast<char *>(malloc(sizeof(char) *
|
||||
x = reinterpret_cast<char *>(calloc(sizeof(char),
|
||||
((j - k) + 1)));
|
||||
memset(x, '\0', (j - k) + 1);
|
||||
memcpy(x, (const char *)&input[k], j - k);
|
||||
*d++ = (unsigned char)strtol(x, NULL, 16);
|
||||
free(x);
|
||||
@@ -127,9 +126,8 @@ int HtmlEntityDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
if (j > k) { /* Do we have at least one digit? */
|
||||
/* Decode the entity. */
|
||||
char *x = NULL;
|
||||
x = reinterpret_cast<char *>(malloc(sizeof(char) *
|
||||
x = reinterpret_cast<char *>(calloc(sizeof(char),
|
||||
((j - k) + 1)));
|
||||
memset(x, '\0', (j - k) + 1);
|
||||
memcpy(x, (const char *)&input[k], j - k);
|
||||
*d++ = (unsigned char)strtol(x, NULL, 10);
|
||||
free(x);
|
||||
@@ -154,9 +152,8 @@ int HtmlEntityDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
}
|
||||
if (j > k) { /* Do we have at least one digit? */
|
||||
char *x = NULL;
|
||||
x = reinterpret_cast<char *>(malloc(sizeof(char) *
|
||||
x = reinterpret_cast<char *>(calloc(sizeof(char),
|
||||
((j - k) + 1)));
|
||||
memset(x, '\0', (j - k) + 1);
|
||||
memcpy(x, (const char *)&input[k], j - k);
|
||||
|
||||
/* Decode the entity. */
|
||||
|
||||
@@ -47,14 +47,12 @@ std::string RemoveComments::evaluate(std::string value,
|
||||
|
||||
u_int64_t input_len = value.size();
|
||||
u_int64_t i, j, incomment;
|
||||
int changed = 0;
|
||||
|
||||
i = j = incomment = 0;
|
||||
while (i < input_len) {
|
||||
if (incomment == 0) {
|
||||
if ((input[i] == '/') && (i + 1 < input_len)
|
||||
&& (input[i + 1] == '*')) {
|
||||
changed = 1;
|
||||
incomment = 1;
|
||||
i += 2;
|
||||
} else if ((input[i] == '<') && (i + 1 < input_len)
|
||||
@@ -62,15 +60,12 @@ std::string RemoveComments::evaluate(std::string value,
|
||||
&& (input[i+2] == '-') && (i + 3 < input_len)
|
||||
&& (input[i + 3] == '-') && (incomment == 0)) {
|
||||
incomment = 1;
|
||||
changed = 1;
|
||||
i += 4;
|
||||
} else if ((input[i] == '-') && (i + 1 < input_len)
|
||||
&& (input[i + 1] == '-') && (incomment == 0)) {
|
||||
changed = 1;
|
||||
input[i] = ' ';
|
||||
break;
|
||||
} else if (input[i] == '#' && (incomment == 0)) {
|
||||
changed = 1;
|
||||
input[i] = ' ';
|
||||
break;
|
||||
} else {
|
||||
|
||||
@@ -59,10 +59,10 @@ std::string Utf8ToUnicode::evaluate(std::string value,
|
||||
|
||||
char *Utf8ToUnicode::inplace(unsigned char *input,
|
||||
uint64_t input_len, int *changed) {
|
||||
int unicode_len = 0, length = 0;
|
||||
unsigned int d = 0, count = 0;
|
||||
unsigned char c, *utf;
|
||||
char *rval, *data;
|
||||
int length = 0;
|
||||
unsigned int count = 0;
|
||||
unsigned char c;
|
||||
char *data;
|
||||
unsigned int i, len, j;
|
||||
unsigned int bytes_left = input_len;
|
||||
unsigned char unicode[8];
|
||||
@@ -75,12 +75,14 @@ char *Utf8ToUnicode::inplace(unsigned char *input,
|
||||
}
|
||||
|
||||
if (input == NULL) {
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < bytes_left;) {
|
||||
unicode_len = 0; d = 0;
|
||||
utf = (unsigned char *)&input[i];
|
||||
int unicode_len = 0;
|
||||
unsigned int d = 0;
|
||||
unsigned char *utf = (unsigned char *)&input[i];
|
||||
|
||||
c = *utf;
|
||||
|
||||
@@ -293,7 +295,7 @@ char *Utf8ToUnicode::inplace(unsigned char *input,
|
||||
|
||||
*data ='\0';
|
||||
|
||||
return NULL;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user