mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Fixed URL decoding with invalid encoding. See #439.
This commit is contained in:
parent
a210e73257
commit
9551218d23
@ -733,20 +733,16 @@ int urldecode_uni_nonstrict_inplace_ex(unsigned char *input, long int input_len)
|
|||||||
count++;
|
count++;
|
||||||
i += 6;
|
i += 6;
|
||||||
} else {
|
} else {
|
||||||
/* Invalid data. */
|
/* Invalid data, skip %u. */
|
||||||
int j;
|
*d++ = input[i++];
|
||||||
|
*d++ = input[i++];
|
||||||
for(j = 0; (j < 6)&&(i < input_len); j++) {
|
count += 2;
|
||||||
*d++ = input[i++];
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Not enough bytes available (4 data bytes were needed). */
|
/* Not enough bytes (4 data bytes), skip %u. */
|
||||||
while(i < input_len) {
|
*d++ = input[i++];
|
||||||
*d++ = input[i++];
|
*d++ = input[i++];
|
||||||
count++;
|
count += 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -766,25 +762,14 @@ int urldecode_uni_nonstrict_inplace_ex(unsigned char *input, long int input_len)
|
|||||||
count++;
|
count++;
|
||||||
i += 3;
|
i += 3;
|
||||||
} else {
|
} else {
|
||||||
/* Not a valid encoding, copy the raw input bytes. */
|
/* Not a valid encoding, skip this % */
|
||||||
*d++ = '%';
|
*d++ = input[i++];
|
||||||
*d++ = c1;
|
count++;
|
||||||
*d++ = c2;
|
|
||||||
count += 3;
|
|
||||||
i += 3;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Not enough bytes available. */
|
/* Not enough bytes available, skip this % */
|
||||||
|
*d++ = input[i++];
|
||||||
*d++ = '%';
|
|
||||||
count++;
|
count++;
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i + 1 < input_len) {
|
|
||||||
*d++ = input[i];
|
|
||||||
count++;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,27 +817,16 @@ int urldecode_nonstrict_inplace_ex(unsigned char *input, long int input_len, int
|
|||||||
count++;
|
count++;
|
||||||
i += 3;
|
i += 3;
|
||||||
} else {
|
} else {
|
||||||
/* Invalid encoding, just copy the raw bytes. */
|
/* Not a valid encoding, skip this % */
|
||||||
*d++ = '%';
|
*d++ = input[i++];
|
||||||
*d++ = c1;
|
count ++;
|
||||||
*d++ = c2;
|
|
||||||
count += 3;
|
|
||||||
i += 3;
|
|
||||||
(*invalid_count)++; /* parens quiet compiler warning */
|
(*invalid_count)++; /* parens quiet compiler warning */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Not enough bytes available, copy the raw bytes. */
|
/* Not enough bytes available, copy the raw bytes. */
|
||||||
|
*d++ = input[i++];
|
||||||
|
count ++;
|
||||||
(*invalid_count)++; /* parens quiet compiler warning */
|
(*invalid_count)++; /* parens quiet compiler warning */
|
||||||
|
|
||||||
*d++ = '%';
|
|
||||||
count++;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i + 1 < input_len) {
|
|
||||||
*d++ = input[i];
|
|
||||||
count++;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Character is not a percent sign. */
|
/* Character is not a percent sign. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user