Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

hi_norm.c File Reference

Contains normalization skeleton for server and client normalization routines. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include "hi_client_norm.h"
#include "hi_eo.h"
#include "hi_eo_events.h"
#include "hi_eo_log.h"
#include "hi_ui_iis_unicode_map.h"
#include "hi_return_codes.h"
#include "hi_si.h"
#include "hi_util.h"
#include "hi_util_xmalloc.h"

Go to the source code of this file.

Defines

#define MAX_DIRS   2048
#define NO_HEX_VAL   -1
#define BASE36_VAL   -2
#define HEX_VAL   1
#define GET_ERR   0x80000000
#define END_OF_BUFFER   -1
#define DOUBLE_ENCODING   -2
#define DIR_TRAV   -2
#define NON_ASCII_CHAR   0xff

Typedefs

typedef s_URI_NORM_STATE URI_NORM_STATE
typedef int(* DECODE_FUNC )(HI_SESSION *, u_char *, u_char *, u_char **, URI_NORM_STATE *)

Functions

static int GetPtr (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, URI_NORM_STATE *norm_state)
static int UDecode (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, DECODE_FUNC get_byte, URI_NORM_STATE *norm_state)
static int PercentDecode (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, URI_NORM_STATE *norm_state)
static int GetChar (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, int *bare_byte, URI_NORM_STATE *norm_state)
static int UTF8Decode (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, int iFirst, URI_NORM_STATE *norm_state)
static int UnicodeDecode (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, int iFirst, URI_NORM_STATE *norm_state)
static int GetByte (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, URI_NORM_STATE *norm_state)
static int DoubleDecode (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, URI_NORM_STATE *norm_state)
static int GetDecodedByte (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, URI_NORM_STATE *norm_state)
static int DirTrav (HI_SESSION *Session, URI_NORM_STATE *norm_state, u_char *ub_start, u_char **ub_ptr)
static int DirSet (URI_NORM_STATE *norm_state, u_char **ub_ptr)
static int DirNorm (HI_SESSION *Session, u_char *start, u_char *end, u_char **ptr, URI_NORM_STATE *norm_state)
static int CheckLongDir (HI_SESSION *Session, URI_NORM_STATE *norm_state, u_char *ub_ptr)
static INLINE int InspectUriChar (HI_SESSION *Session, int iChar, URI_NORM_STATE *norm_state, u_char *start, u_char *end, u_char **ptr, u_char *ub_start, u_char *ub_end, u_char **ub_ptr)
int hi_norm_uri (HI_SESSION *Session, u_char *uribuf, int *uribuf_size, u_char *uri, int uri_size)
int hi_norm_init (HTTPINSPECT_GLOBAL_CONF *GlobalConf)
int hi_normalization (HI_SESSION *Session, int iInspectMode)

Variables

static int hex_lookup [256]
static int valid_lookup [256]


Detailed Description

Contains normalization skeleton for server and client normalization routines.

Author:
Daniel Roelker <droelker@sourcefire.com
This file contains the core routines to normalize the different fields within the HTTP protocol. We currently only support client URI normalization, but the hooks are here to easily add other routines.

NOTES:

Definition in file hi_norm.c.


Define Documentation

#define BASE36_VAL   -2
 

Definition at line 35 of file hi_norm.c.

Referenced by hi_norm_init(), and PercentDecode().

#define DIR_TRAV   -2
 

Definition at line 46 of file hi_norm.c.

Referenced by DirNorm(), and InspectUriChar().

#define DOUBLE_ENCODING   -2
 

Definition at line 45 of file hi_norm.c.

Referenced by GetPtr(), and PercentDecode().

#define END_OF_BUFFER   -1
 

Definition at line 44 of file hi_norm.c.

Referenced by DirNorm(), DoubleDecode(), GetByte(), GetChar(), GetDecodedByte(), GetPtr(), hi_norm_uri(), InspectUriChar(), PercentDecode(), and UTF8Decode().

#define GET_ERR   0x80000000
 

This define checks for negative return codes, since we have multiple reasons to error. This just cuts the return code checks, especially as we add more errors.

Definition at line 43 of file hi_norm.c.

Referenced by PercentDecode(), and UDecode().

#define HEX_VAL   1
 

Definition at line 36 of file hi_norm.c.

Referenced by hi_norm_init().

#define MAX_DIRS   2048
 

Definition at line 32 of file hi_norm.c.

Referenced by DirSet().

#define NO_HEX_VAL   -1
 

Definition at line 34 of file hi_norm.c.

Referenced by hi_norm_init().

#define NON_ASCII_CHAR   0xff
 

Definition at line 48 of file hi_norm.c.

Referenced by DoubleDecode(), GetByte(), GetChar(), PercentDecode(), UDecode(), and UTF8Decode().


Typedef Documentation

typedef int(* DECODE_FUNC)(HI_SESSION *, u_char *, u_char *, u_char **, URI_NORM_STATE *)
 

Definition at line 63 of file hi_norm.c.

typedef struct s_URI_NORM_STATE URI_NORM_STATE
 


Function Documentation

static int CheckLongDir HI_SESSION Session,
URI_NORM_STATE norm_state,
u_char *  ub_ptr
[static]
 

This function checks for long directory names in the request URI.

Parameters:
Session pointer to the session
norm_state pointer to the directory stack
ub_ptr current pointer in normalization buffer
Returns:
integer
Return values:
HI_SUCCESS 

Definition at line 1136 of file hi_norm.c.

References s_URI_NORM_STATE::dir_count, s_URI_NORM_STATE::dir_track, hi_eo_client_event_log(), HI_EO_CLIENT_OVERSIZE_DIR, hi_eo_generate_event(), HI_SUCCESS, s_HTTPINSPECT_CONF::long_dir, NULL, s_URI_NORM_STATE::param, and s_HI_SESSION::server_conf.

static int DirNorm HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
URI_NORM_STATE norm_state
[static]
 

The main function for dealing with multiple slashes, self-referential directories, and directory traversals.

This routine does GetDecodedByte() while looking for directory foo. It's called every time that we see a slash in the main hi_norm_uri. Most of the time we just enter this loop, find a non-directory-foo char and return that char. hi_norm_uri() takes care of the directory state updating and so forth.

But when we run into trouble with directories, this function takes care of that. We loop through multiple slashes until we get to the next directory. We also loop through self-referential directories until we get to the next directory. Then finally we deal with directory traversals.

With directory traversals we do a kind of "look ahead". We verify that there is indeed a directory traversal, and then set the ptr back to the beginning of the '/', so when we iterate through hi_norm_uri() we catch it.

The return value for this function is usually the character after the directory. When there was a directory traversal, it returns the value DIR_TRAV. And when END_OF_BUFFER is returned, it means that we've really hit the end of the buffer, or we were looping through multiple slashes and self-referential directories until the end of the URI buffer.

Parameters:
ServerConf pointer to the Server configuration
start pointer to the start of the URI buffer
end pointer to the end of the URI buffer
ptr pointer to the index in the URI buffer
Returns:
integer
Return values:
END_OF_BUFFER we've reached the end of buffer
DIR_TRAV we found a directory traversal
char return the next char after the directory
See also:
hi_norm_uri()

GetDecodedByte()

Definition at line 996 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, DIR_TRAV, s_HTTPINSPECT_CONF::directory, END_OF_BUFFER, GetDecodedByte(), HI_EO_CLIENT_DIR_TRAV, hi_eo_client_event_log(), HI_EO_CLIENT_MULTI_SLASH, HI_EO_CLIENT_SELF_DIR_TRAV, hi_eo_generate_event(), s_HTTPINSPECT_CONF::multiple_slash, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, and s_HI_SESSION::server_conf.

Referenced by InspectUriChar().

static int DirSet URI_NORM_STATE norm_state,
u_char **  ub_ptr
[static]
 

Set the directory by writing a '/' to the normalization buffer and updating the directory stack.

This gets called after every slash that isn't a directory traversal. We just write a '/' and then update the directory stack to point to the last directory, in the case of future directory traversals.

Parameters:
norm_state pointer to the normalization state struct
ub_ptr double pointer to the normalized buffer
Returns:
integer
Return values:
HI_SUCCESS function successful
See also:
hi_norm_uri()

Definition at line 930 of file hi_norm.c.

References s_URI_NORM_STATE::dir_count, s_URI_NORM_STATE::dir_track, HI_SUCCESS, MAX_DIRS, and s_URI_NORM_STATE::param.

Referenced by InspectUriChar().

static int DirTrav HI_SESSION Session,
URI_NORM_STATE norm_state,
u_char *  ub_start,
u_char **  ub_ptr
[static]
 

Set the ub_ptr and update the URI_NORM_STATE.

The main point of this function is to take care of the details in updating the directory stack and setting the buffer pointer to the last directory.

Parameters:
norm_state pointer to the normalization state struct
ub_ptr double pointer to the normalized buffer
Returns:
integer
Return values:
HI_SUCCESS function successful
See also:
hi_norm_uri()

Definition at line 868 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, s_URI_NORM_STATE::dir_count, s_URI_NORM_STATE::dir_track, hi_eo_client_event_log(), HI_EO_CLIENT_WEBROOT_DIR, hi_eo_generate_event(), HI_SUCCESS, NULL, s_URI_NORM_STATE::param, s_HI_SESSION::server_conf, and s_HTTPINSPECT_CONF::webroot.

Referenced by InspectUriChar().

static int DoubleDecode HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
URI_NORM_STATE norm_state
[static]
 

The double decoding routine for IIS good times.

Coming into this function means that we just decoded a % or that we just saw two percents in a row. We know which state we are in depending if the first char is a '' or not.

In the IIS world, there are two decodes, but only some of the decode options are valid. All options are valid in the first decode stage, but the second decode stage only supports:

  • u encoding
  • ascii

Knowing this, we can decode appropriately.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
norm_state the ptr to the URI norm state
Returns:
integer
Return values:
NON_ASCII_CHAR End of buffer reached while decoding
char The decoded char

Definition at line 706 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, s_HTTPINSPECT_CONF::double_decoding, END_OF_BUFFER, GetByte(), hex_lookup, HI_EO_CLIENT_DOUBLE_DECODE, hi_eo_client_event_log(), hi_eo_generate_event(), NON_ASCII_CHAR, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, s_HI_SESSION::server_conf, s_HTTPINSPECT_CONF::u_encoding, UDecode(), and valid_lookup.

Referenced by GetDecodedByte().

static int GetByte HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
URI_NORM_STATE norm_state
[static]
 

Handles the first stage of URI decoding for the case of IIS double decoding.

The first stage consists of ASCII decoding and unicode decoding. U decoding is handled in the ASCII decoding.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
Returns:
integer
Return values:
END_OF_BUFFER means that we've reached the end of buffer in GetChar.
iChar this is the character that was decoded.

Definition at line 655 of file hi_norm.c.

References END_OF_BUFFER, GetChar(), NON_ASCII_CHAR, and UnicodeDecode().

Referenced by DoubleDecode(), and GetDecodedByte().

static int GetChar HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
int *  bare_byte,
URI_NORM_STATE norm_state
[static]
 

Wrapper for PercentDecode() and handles the return values from PercentDecode().

This really decodes the chars for UnicodeDecode(). If the char is a percent then we process stuff, otherwise we just increment the pointer and return.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
bare_byte value for a non-ASCII char or a decoded non-ASCII char
Returns:
integer
Return values:
END_OF_BUFFER End of the buffer has been reached before decode.
NON_ASCII_CHAR End of buffer during decoding, return decoded char.
char return the valid decoded/undecoded char
See also:
PercentDecode()

GetByte()

Definition at line 407 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, s_HTTPINSPECT_CONF::ascii, s_HTTPINSPECT_CONF::bare_byte, END_OF_BUFFER, HI_EO_CLIENT_BARE_BYTE, hi_eo_client_event_log(), hi_eo_generate_event(), hi_util_in_bounds(), int(), NON_ASCII_CHAR, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, PercentDecode(), and s_HI_SESSION::server_conf.

Referenced by GetByte(), and UTF8Decode().

static int GetDecodedByte HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
URI_NORM_STATE norm_state
[static]
 

This is the final GetByte routine. The value that is returned from this routine is the final decoded byte, and normalization can begin. This routine handles the double phase of decoding that IIS is fond of.

So to recap all the decoding up until this point.

The first phase is to call GetByte(). GetByte() returns the first stage of decoding, which handles the UTF-8 decoding. If we have decoded a % of some type, then we head into DoubleDecode() if the ServerConf allows it.

What returns from DoubleDecode is the final result.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
norm_state the pointer to the URI norm state
Returns:
integer
Return values:
END_OF_BUFFER While decoding, the end of buffer was reached.
char The resultant decoded char.
See also:
DoubleDecode();

GetByte();

Definition at line 814 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, s_HTTPINSPECT_CONF::double_decoding, DoubleDecode(), END_OF_BUFFER, GetByte(), hi_eo_client_event_log(), HI_EO_CLIENT_IIS_BACKSLASH, hi_eo_generate_event(), s_HTTPINSPECT_CONF::iis_backslash, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, and s_HI_SESSION::server_conf.

Referenced by DirNorm(), and hi_norm_uri().

static int GetPtr HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
URI_NORM_STATE norm_state
[static]
 

This routine is for getting bytes in the U decode.

This checks the current bounds and checking for the double decoding. This routine differs from the other Get routines because it returns other values than just END_OF_BUFFER and the char.

We also return DOUBLE_ENCODING if there is a % and double decoding is turned on.

When using this function it is important to note that it increments the buffer before checking the bounds. So, if you call this function in a loop and don't check for END_OF_BUFFER being returned, then you are going to overwrite the buffer. If I put the check in, you would just be in an never-ending loop. So just use this correctly.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
Returns:
integer
Return values:
END_OF_BUFFER the end of the buffer has been reached.
DOUBLE_ENCODING a percent was found and double decoding is on
<= 0xff an ASCII char

Definition at line 100 of file hi_norm.c.

References s_HTTPINSPECT_CONF::double_decoding, DOUBLE_ENCODING, END_OF_BUFFER, hi_util_in_bounds(), s_HTTPINSPECT_CONF_OPT::on, and s_HI_SESSION::server_conf.

Referenced by PercentDecode().

int hi_norm_init HTTPINSPECT_GLOBAL_CONF GlobalConf  ) 
 

Initialize the arrays neccessary to normalize the HTTP protocol fields.

Currently, we set a hex_lookup array where we can convert the hex encoding that we encounter in the URI into numbers we deal with.

Parameters:
GlobalConf pointer to the global configuration of HttpInspect
Returns:
HI_SUCCESS function successful

Definition at line 1477 of file hi_norm.c.

References BASE36_VAL, hex_lookup, HEX_VAL, HI_SUCCESS, memset, NO_HEX_VAL, and valid_lookup.

Referenced by HttpInspectInit().

int hi_norm_uri HI_SESSION Session,
u_char *  uribuf,
int *  uribuf_size,
u_char *  uri,
int  uri_size
 

Normalize the URI into the URI normalize buffer.

This is the routine that users call to normalize the URI. It iterates through the URI buffer decoding the next character and is then checked for any directory problems before writing the decoded character into the normalizing buffer.

We return the length of the normalized URI buffer in the variable, uribuf_size. This value is passed in as the max size of the normalization buffer, which we then set in iMaxUriBufSize for later reference.

If there was some sort of problem during normalizing we set the normalized URI buffer size to 0 and return HI_NONFATAL_ERR.

Parameters:
ServerConf the pointer to the server configuration
uribuf the pointer to the normalize uri buffer
uribuf_size the size of the normalize buffer
uri the pointer to the unnormalized uri buffer
uri_size the size of the unnormalized uri buffer
Returns:
integer
Return values:
HI_NONFATAL_ERR there was a problem during normalizing, the uribuf_size is also set to 0
HI_SUCCESS Normalizing the URI was successful

Definition at line 1376 of file hi_norm.c.

References CheckLongDir(), s_URI_NORM_STATE::dir_count, END_OF_BUFFER, GetDecodedByte(), hi_eo_client_event_log(), HI_EO_CLIENT_NON_RFC_CHAR, hi_eo_generate_event(), HI_NONFATAL_ERR, HI_SUCCESS, hi_util_in_bounds(), InspectUriChar(), s_HTTPINSPECT_CONF::non_rfc_chars, NULL, s_URI_NORM_STATE::param, and s_HI_SESSION::server_conf.

Referenced by UriNorm().

int hi_normalization HI_SESSION Session,
int  iInspectMode
 

Wrap the logic for normalizing different inspection modes.

We call the various normalization modes here, and adjust the appropriate Session constructs.

Parameters:
Session pointer to the session structure.
iInspectMode the type of inspection/normalization to do
Returns:
integer
Return values:
HI_SUCCESS function successful
HI_INVALID_ARG invalid argument

Definition at line 1555 of file hi_norm.c.

References hi_client_norm(), HI_INVALID_ARG, HI_SI_CLIENT_MODE, and HI_SUCCESS.

Referenced by SnortHttpInspect().

static INLINE int InspectUriChar HI_SESSION Session,
int  iChar,
URI_NORM_STATE norm_state,
u_char *  start,
u_char *  end,
u_char **  ptr,
u_char *  ub_start,
u_char *  ub_end,
u_char **  ub_ptr
[static]
 

This function inspects the normalized chars for any other processing that we need to do, such as directory traversals.

The main things that we check for here are '/' and '?'. There reason for '/' is that we do directory traversals. If it's a slash, we call the routine that will normalize mutli-slashes, self-referential dirs, and dir traversals. We do all that processing here and call the appropriate functions.

The '?' is so we can mark the parameter field, and check for oversize directories one last time. Once the parameter field is set, we don't do any more oversize directory checks since we aren't in the url any more.

Parameters:
Session pointer to the current session
iChar the char to inspect
norm_state the normalization state
start the start of the URI buffer
end the end of the URI buffer
ptr the address of the pointer index into the URI buffer
ub_start the start of the norm buffer
ub_end the end of the norm buffer
ub_ptr the address of the pointer index into the norm buffer
Returns:
integer
Return values:
END_OF_BUFFER we've reached the end of the URI or norm buffer
HI_NONFATAL_ERR no special char, so just write the char and increment the ub_ptr.
HI_SUCCESS normalized the special char and already incremented the buffers.

Definition at line 1202 of file hi_norm.c.

References CheckLongDir(), s_URI_NORM_STATE::dir_count, DIR_TRAV, DirNorm(), DirSet(), DirTrav(), END_OF_BUFFER, hi_eo_client_event_log(), HI_EO_CLIENT_NON_RFC_CHAR, hi_eo_generate_event(), HI_NONFATAL_ERR, HI_SUCCESS, hi_util_in_bounds(), s_HTTPINSPECT_CONF::non_rfc_chars, NULL, s_URI_NORM_STATE::param, and s_HI_SESSION::server_conf.

Referenced by hi_norm_uri().

static int PercentDecode HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
URI_NORM_STATE norm_state
[static]
 

This is the first level of decoding, and deals with ASCII, U, and double decoding.

This function is the main decoding function. It handles all the ASCII encoding and the U encoding, and tells us when there is a double encoding.

We use the GetPtr() routine to get the bytes for us. This routine checks for DOUBLE_ENCODING and tells us about it if it finds something, so we can reset the ptrs and run it through the double decoding routine.

The philosophy behind this routine is that if we run out of buffer we return such, the only other thing we return besides the decodes char is a NON_ASCII_CHAR in the case that we try and decode something like tt. This is no good, so we return a place holder.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
Returns:
integer
Return values:
END_OF_BUFFER We've hit the end of buffer while decoding.
NON_ASCII_CHAR Invalid hex encoding, so we return a placeholder.
char return the valid char
See also:
GetPtr()

Definition at line 253 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, s_HTTPINSPECT_CONF::ascii, s_HTTPINSPECT_CONF::base36, BASE36_VAL, DOUBLE_ENCODING, END_OF_BUFFER, GET_ERR, GetPtr(), hex_lookup, HI_EO_CLIENT_ASCII, HI_EO_CLIENT_BASE36, hi_eo_client_event_log(), hi_eo_generate_event(), NON_ASCII_CHAR, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, s_HI_SESSION::server_conf, s_HTTPINSPECT_CONF::u_encoding, UDecode(), and valid_lookup.

Referenced by GetChar().

static int UDecode HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
DECODE_FUNC  get_byte,
URI_NORM_STATE norm_state
[static]
 

Handles the single decode for U encoding.

This routine receives the ptr pointing to the u. We check the bounds and continue with processing. u encoding works by specifying the exact codepoint to be used. For example, u002f would be /. So this all seems fine. BUT, the problem is that IIS maps multiple codepoints to ASCII characters. So, u2044 also maps to /. So this is what we need to handle here.

This routine only handles the single encoding. For double decoding, u is handled in DoubleDecode(). It's the same routine, with just the GetByte function different.

We use a get_byte function to get the bytes, so we can use this routine for PercentDecode and for DoubleDecode.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
get_byte the function pointer to get bytes.
Returns:
integer
Return values:
END_OF_BUFFER we are at the end of the buffer
DOUBLE_ENCODING this U encoding is possible double encoded
NON_ASCII_CHAR return this char for non-ascii or bad decodes
iChar this is the char that we decoded.

Definition at line 150 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, GET_ERR, hex_lookup, hi_eo_client_event_log(), HI_EO_CLIENT_IIS_UNICODE, HI_EO_CLIENT_U_ENCODE, hi_eo_generate_event(), HI_UI_NON_ASCII_CODEPOINT, s_HTTPINSPECT_CONF::iis_unicode, s_HTTPINSPECT_CONF::iis_unicode_map, NON_ASCII_CHAR, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, s_HTTPINSPECT_CONF::u_encoding, and valid_lookup.

Referenced by DoubleDecode(), and PercentDecode().

static int UnicodeDecode HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
int  iFirst,
URI_NORM_STATE norm_state
[static]
 

Checks for the ServerConf values before we actually decode.

This function is really a ServerConf wrapper for UTF8Decode.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
Returns:
integer
Return values:
char the decode/undecoded byte.
See also:
GetByte()

Definition at line 618 of file hi_norm.c.

References s_HTTPINSPECT_CONF::iis_unicode, s_HTTPINSPECT_CONF_OPT::on, s_HI_SESSION::server_conf, UTF8Decode(), and s_HTTPINSPECT_CONF::utf_8.

Referenced by GetByte().

static int UTF8Decode HI_SESSION Session,
u_char *  start,
u_char *  end,
u_char **  ptr,
int  iFirst,
URI_NORM_STATE norm_state
[static]
 

Decode the UTF-8 sequences and check for valid codepoints via the Unicode standard and the IIS standard.

We decode up to 3 bytes of UTF-8 because that's all I've been able to get to work on various servers, so let's reduce some false positives. So we decode valid UTF-8 sequences and then check the value. If the value is ASCII, then it's decoded to that. Otherwise, if iis_unicode is turned on, we will check the unicode codemap for valid IIS mappings. If a mapping turns up, then we return the mapped ASCII.

Parameters:
ServerConf the server configuration
start the start of the URI
end the end of the URI
ptr the current pointer into the URI
Returns:
integer
Return values:
NON_ASCII_CHAR Reached end of buffer while decoding
char return the decoded or badly decoded char
See also:
GetByte()

UnicodeDecode()

Definition at line 497 of file hi_norm.c.

References s_HTTPINSPECT_CONF_OPT::alert, END_OF_BUFFER, GetChar(), hi_eo_client_event_log(), HI_EO_CLIENT_IIS_UNICODE, HI_EO_CLIENT_UTF_8, hi_eo_generate_event(), HI_UI_NON_ASCII_CODEPOINT, s_HTTPINSPECT_CONF::iis_unicode, s_HTTPINSPECT_CONF::iis_unicode_map, NON_ASCII_CHAR, NULL, s_HTTPINSPECT_CONF_OPT::on, s_URI_NORM_STATE::param, s_HI_SESSION::server_conf, and s_HTTPINSPECT_CONF::utf_8.

Referenced by UnicodeDecode().


Variable Documentation

int hex_lookup[256] [static]
 

Definition at line 66 of file hi_norm.c.

int valid_lookup[256] [static]
 

Definition at line 67 of file hi_norm.c.

Referenced by DoubleDecode(), hi_norm_init(), PercentDecode(), and UDecode().


Generated on Sun May 14 14:51:25 2006 by  doxygen 1.4.2