mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Revert hexDecode and add new sqlHexDecode
This commit is contained in:
@@ -419,15 +419,20 @@ char *file_dirname(apr_pool_t *p, const char *filename) {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int hex2bytes_inplace(unsigned char *data, int len) {
|
int sql_hex2bytes_inplace(unsigned char *data, int len) {
|
||||||
unsigned char *d = data;
|
unsigned char *d = data;
|
||||||
char print = 0;
|
char print = 0, found = 0;
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
|
|
||||||
if ((data == NULL)||(len == 0)) return 0;
|
if ((data == NULL)||(len == 0)) return 0;
|
||||||
|
|
||||||
for(i = 0; i <= len - 1; i++) {
|
for(i = 0; i <= len - 1; i++) {
|
||||||
if(VALID_HEX(data[i]) && VALID_HEX(data[i+1])) {
|
if(data[i] == 0x30 && data[i+1] == 0x78) {
|
||||||
|
found = 1;
|
||||||
|
i++; continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(VALID_HEX(data[i]) && VALID_HEX(data[i+1]) && found) {
|
||||||
print = data[i];
|
print = data[i];
|
||||||
if(print > 0x31 && print < 0x38) {
|
if(print > 0x31 && print < 0x38) {
|
||||||
*d++ = x2c(&data[i]);
|
*d++ = x2c(&data[i]);
|
||||||
@@ -441,6 +446,26 @@ int hex2bytes_inplace(unsigned char *data, int len) {
|
|||||||
} else {
|
} else {
|
||||||
*d++ = data[i];
|
*d++ = data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
*d = '\0';
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int hex2bytes_inplace(unsigned char *data, int len) {
|
||||||
|
unsigned char *d = data;
|
||||||
|
int i, count = 0;
|
||||||
|
|
||||||
|
if ((data == NULL)||(len == 0)) return 0;
|
||||||
|
|
||||||
|
for(i = 0; i <= len - 2; i += 2) {
|
||||||
|
*d++ = x2c(&data[i]);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
*d = '\0';
|
*d = '\0';
|
||||||
|
@@ -43,6 +43,8 @@ char DSOLOCAL *file_dirname(apr_pool_t *p, const char *filename);
|
|||||||
|
|
||||||
char DSOLOCAL *file_basename(apr_pool_t *p, const char *filename);
|
char DSOLOCAL *file_basename(apr_pool_t *p, const char *filename);
|
||||||
|
|
||||||
|
int DSOLOCAL sql_hex2bytes_inplace(unsigned char *data, int len);
|
||||||
|
|
||||||
int DSOLOCAL hex2bytes_inplace(unsigned char *data, int len);
|
int DSOLOCAL hex2bytes_inplace(unsigned char *data, int len);
|
||||||
|
|
||||||
char DSOLOCAL *bytes2hex(apr_pool_t *pool, unsigned char *data, int len);
|
char DSOLOCAL *bytes2hex(apr_pool_t *pool, unsigned char *data, int len);
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
type => "tfn",
|
type => "tfn",
|
||||||
name => "hexDecode",
|
name => "hexDecode",
|
||||||
input => "546573740043617365",
|
input => "546573740043617365",
|
||||||
output => "Test00Case",
|
output => "Test\0Case",
|
||||||
ret => 1,
|
ret => 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -31,20 +31,20 @@
|
|||||||
type => "tfn",
|
type => "tfn",
|
||||||
name => "hexDecode",
|
name => "hexDecode",
|
||||||
input => "01234567890a0z01234567890a",
|
input => "01234567890a0z01234567890a",
|
||||||
output => "01#Eg890a0z01#Eg890a",
|
output => "\x01#Eg\x89\x0a#\x01#Eg\x89\x0a",
|
||||||
ret => 1,
|
ret => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type => "tfn",
|
type => "tfn",
|
||||||
name => "hexDecode",
|
name => "hexDecode",
|
||||||
input => "01234567890az",
|
input => "01234567890az",
|
||||||
output => "01#Eg890az",
|
output => "\x01#Eg\x89\x0a",
|
||||||
ret => 1,
|
ret => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type => "tfn",
|
type => "tfn",
|
||||||
name => "hexDecode",
|
name => "hexDecode",
|
||||||
input => "01234567890a0",
|
input => "01234567890a0",
|
||||||
output => "01#Eg890a0",
|
output => "\x01#Eg\x89\x0a",
|
||||||
ret => 1,
|
ret => 1,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user