|
Packit |
284210 |
/*
|
|
Packit |
284210 |
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
|
|
Packit |
284210 |
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
|
Packit |
284210 |
*
|
|
Packit |
284210 |
* You may not use this file except in compliance with
|
|
Packit |
284210 |
* the License. You may obtain a copy of the License at
|
|
Packit |
284210 |
*
|
|
Packit |
284210 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
284210 |
*
|
|
Packit |
284210 |
* If any of the files related to licensing are missing or if you have any
|
|
Packit |
284210 |
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
|
Packit |
284210 |
* directly using the email address security@modsecurity.org.
|
|
Packit |
284210 |
*/
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifndef _UTIL_H_
|
|
Packit |
284210 |
#define _UTIL_H_
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#include <sys/types.h>
|
|
Packit |
284210 |
#include <apr_file_info.h>
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifndef APR_WSTICKY
|
|
Packit |
284210 |
/* Add extra flags added to APR in 0.9.5 */
|
|
Packit |
284210 |
#define APR_USETID 0x8000 /**< Set user id */
|
|
Packit |
284210 |
#define APR_GSETID 0x4000 /**< Set group id */
|
|
Packit |
284210 |
#define APR_WSTICKY 0x2000 /**< Sticky bit */
|
|
Packit |
284210 |
#endif
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#include "modsecurity.h"
|
|
Packit |
284210 |
#include "re.h"
|
|
Packit |
284210 |
#include "msc_tree.h"
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifdef WIN32
|
|
Packit |
284210 |
#include <ws2tcpip.h>
|
|
Packit |
284210 |
// This is a trick: for ModSecurity modules this will declare inet_pton,
|
|
Packit |
284210 |
// but for mymodule.cpp (IIS module) this will skip, because we include
|
|
Packit |
284210 |
// windows.h before including msc_util.h
|
|
Packit |
284210 |
// Without the trick we have redefinition conflict.
|
|
Packit |
284210 |
//
|
|
Packit |
284210 |
#if !(NTDDI_VERSION >= NTDDI_VISTA)
|
|
Packit |
284210 |
int DSOLOCAL inet_pton(int family, const char *src, void *dst);
|
|
Packit |
284210 |
#endif
|
|
Packit |
284210 |
#endif
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#define UNICODE_ERROR_CHARACTERS_MISSING -1
|
|
Packit |
284210 |
#define UNICODE_ERROR_INVALID_ENCODING -2
|
|
Packit |
284210 |
#define UNICODE_ERROR_OVERLONG_CHARACTER -3
|
|
Packit |
284210 |
#define UNICODE_ERROR_RESTRICTED_CHARACTER -4
|
|
Packit |
284210 |
#define UNICODE_ERROR_DECODING_ERROR -5
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifdef LINUX_S390
|
|
Packit |
284210 |
int DSOLOCAL swap_int32(int x);
|
|
Packit |
284210 |
#endif
|
|
Packit |
284210 |
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *utf8_unicode_inplace_ex(apr_pool_t *mp, unsigned char *input, long int input_len, int *changed);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *m_strcasestr(const char *haystack, const char *needle);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL normalize_path_inplace(unsigned char *input, int len, int win, int *changed);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL parse_boolean(const char *input);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *remove_quotes(apr_pool_t *mptmp, const char *input, int input_len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *parse_pm_content(const char *op_parm, unsigned short int op_len, msre_rule *rule, char **error_msg);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *remove_escape(apr_pool_t *mptmp, const char *input, int input_len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL parse_name_eq_value(apr_pool_t *mp, const char *input, char **name, char **value);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *url_encode(apr_pool_t *mp, char *input, unsigned int input_len, int *changed);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *strnurlencat(char *destination, char *source, unsigned int maxlen);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *file_dirname(apr_pool_t *p, const char *filename);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *file_basename(apr_pool_t *p, const char *filename);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL sql_hex2bytes_inplace(unsigned char *data, int len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL hex2bytes_inplace(unsigned char *data, int len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *bytes2hex(apr_pool_t *pool, unsigned char *data, int len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL is_token_char(unsigned char c);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL remove_lf_crlf_inplace(char *text);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *guess_tmp_dir(apr_pool_t *p);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *current_logtime(apr_pool_t *mp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *current_filetime(apr_pool_t *mp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL msc_mkstemp_ex(char *templat, int mode);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL msc_mkstemp(char *templat);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *strtolower_inplace(unsigned char *str);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_re(apr_pool_t *p, const char *text);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape(apr_pool_t *p, const char *text);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_nq(apr_pool_t *p, const char *text);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_ex(apr_pool_t *p, const char *text, unsigned long int text_length);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_nq_ex(apr_pool_t *p, const char *text, unsigned long int text_length);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_hex(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_raw(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *log_escape_nul(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL decode_base64_ext(char *plain_text, const unsigned char *input, int input_len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL convert_to_int(const char c);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL set_match_to_tx(modsec_rec *msr, int capture, const char *match, int tx_n);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL js_decode_nonstrict_inplace(unsigned char *input, long int input_len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL urldecode_uni_nonstrict_inplace_ex(unsigned char *input, long int input_length, int * changed);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL urldecode_nonstrict_inplace_ex(unsigned char *input, long int input_length, int *invalid_count, int *changed);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL html_entities_decode_inplace(apr_pool_t *mp, unsigned char *input, int len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL ansi_c_sequences_decode_inplace(unsigned char *input, int len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *modsec_build(apr_pool_t *mp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL is_empty_string(const char *string);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *resolve_relative_path(apr_pool_t *pool, const char *parent_filename, const char *filename);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL css_decode_inplace(unsigned char *input, long int input_len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
apr_fileperms_t DSOLOCAL mode2fileperms(int mode);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *construct_single_var(modsec_rec *msr, char *name);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char DSOLOCAL *format_all_performance_variables(modsec_rec *msr, apr_pool_t *mp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
unsigned char DSOLOCAL is_netmask_v4(char *ip_strv4);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
unsigned char DSOLOCAL is_netmask_v6(char *ip_strv6);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL msc_headers_to_buffer(const apr_array_header_t *arr, char *buffer, int max_length);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL ip_tree_from_file(TreeRoot **rtree, char *uri,
|
|
Packit |
284210 |
apr_pool_t *mp, char **error_msg);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL tree_contains_ip(apr_pool_t *mp, TreeRoot *rtree,
|
|
Packit |
284210 |
const char *value, modsec_rec *msr, char **error_msg);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int DSOLOCAL ip_tree_from_param(apr_pool_t *pool,
|
|
Packit |
284210 |
char *param, TreeRoot **rtree, char **error_msg);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifdef WITH_CURL
|
|
Packit |
284210 |
int ip_tree_from_uri(TreeRoot **rtree, char *uri,
|
|
Packit |
284210 |
apr_pool_t *mp, char **error_msg);
|
|
Packit |
284210 |
#endif
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int read_line(char *buff, int size, FILE *fp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
size_t msc_curl_write_memory_cb(void *contents, size_t size,
|
|
Packit |
284210 |
size_t nmemb, void *userp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
struct msc_curl_memory_buffer_t
|
|
Packit |
284210 |
{
|
|
Packit |
284210 |
char *memory;
|
|
Packit |
284210 |
size_t size;
|
|
Packit |
284210 |
};
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifdef WIN32
|
|
Packit |
284210 |
char *strtok_r(char *str, const char *delim, char **nextp);
|
|
Packit |
284210 |
#endif
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#endif
|