mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Added logdata action (still needs byte limit). See #40.
This commit is contained in:
@@ -450,13 +450,43 @@ char *log_escape_raw(apr_pool_t *mp, const unsigned char *text, unsigned long in
|
||||
unsigned long int i, j;
|
||||
|
||||
for (i = 0, j = 0; i < text_length; i++, j += 4) {
|
||||
apr_snprintf((char *)ret+j, 5, "\\x%02x", text[i]);
|
||||
ret[j] = '\\';
|
||||
ret[j+1] = 'x';
|
||||
c2x(text[i], ret+j+2);
|
||||
}
|
||||
ret[text_length * 4] = '\0';
|
||||
|
||||
return (char *)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform text to ASCII printable or hex escaped
|
||||
*/
|
||||
char *log_escape_hex(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length) {
|
||||
unsigned char *ret = apr_palloc(mp, text_length * 4 + 1);
|
||||
unsigned long int i, j;
|
||||
|
||||
for (i = 0, j = 0; i < text_length; i++) {
|
||||
if ( (text[i] == '"')
|
||||
||(text[i] == '\\')
|
||||
||(text[i] <= 0x1f)
|
||||
||(text[i] >= 0x7f))
|
||||
{
|
||||
ret[j] = '\\';
|
||||
ret[j+1] = 'x';
|
||||
c2x(text[i], ret+j+2);
|
||||
j += 4;
|
||||
}
|
||||
else {
|
||||
ret[j] = text[i];
|
||||
j ++;
|
||||
}
|
||||
}
|
||||
ret[j] = '\0';
|
||||
|
||||
return (char *)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform input into a form safe for logging.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user