HTP  0.5
htp_multipart_private.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2009-2010 Open Information Security Foundation
3  * Copyright (c) 2010-2013 Qualys, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * - Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12 
13  * - Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16 
17  * - Neither the name of the Qualys, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  ***************************************************************************/
33 
39 #ifndef _HTP_MULTIPART_PRIVATE_H
40 #define _HTP_MULTIPART_PRIVATE_H
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include "htp_multipart.h"
47 
48 #define CD_PARAM_OTHER 0
49 #define CD_PARAM_NAME 1
50 #define CD_PARAM_FILENAME 2
51 
52 #define DEFAULT_FILE_EXTRACT_LIMIT 16
53 
56  MODE_LINE = 0,
57 
60 };
61 
65 
68 
71 
74 
77 
80 
83 };
84 
85 struct htp_mpartp_t {
87 
89 
91 
93 
94  char *extract_dir;
95 
97 
98  // Parsing callbacks
99 
100  int (*handle_data)(htp_mpartp_t *mpartp, const unsigned char *data,
101  size_t len, int line_end);
102  int (*handle_boundary)(htp_mpartp_t *mpartp);
103 
104  // Internal parsing fields; move into a private structure
105 
110 
116 
121 
136 
144 
146 
148 
155 
161 
171  int cr_aside;
172 
179 };
180 
181 htp_status_t htp_mpartp_run_request_file_data_hook(htp_multipart_part_t *part, const unsigned char *data, size_t len);
182 
184 
185 htp_status_t htp_mpartp_parse_header(htp_multipart_part_t *part, const unsigned char *data, size_t len);
186 
187 htp_status_t htp_mpart_part_handle_data(htp_multipart_part_t *part, const unsigned char *data, size_t len, int is_line);
188 
190 
192 
194 
195 void htp_mpart_part_destroy(htp_multipart_part_t *part, int gave_up_data);
196 
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif /* _HTP_MULTIPART_PRIVATE_H */
Definition: htp_config_private.h:123
htp_status_t htp_mpart_part_parse_c_d(htp_multipart_part_t *part)
Definition: htp_multipart.c:101
enum htp_multipart_state_t parser_state
Definition: htp_multipart_private.h:109
htp_status_t htp_mpart_part_handle_data(htp_multipart_part_t *part, const unsigned char *data, size_t len, int is_line)
Definition: htp_multipart.c:602
htp_multipart_part_t * current_part
Definition: htp_multipart_private.h:120
Definition: htp_multipart_private.h:79
htp_multipart_t multipart
Definition: htp_multipart_private.h:86
htp_status_t htp_mpartp_parse_header(htp_multipart_part_t *part, const unsigned char *data, size_t len)
Definition: htp_multipart.c:312
Definition: htp_multipart_private.h:56
Definition: htp_multipart_private.h:70
Definition: htp_multipart.h:248
htp_multipart_state_t
Definition: htp_multipart_private.h:62
htp_status_t htp_mpart_part_process_headers(htp_multipart_part_t *part)
Definition: htp_multipart.c:297
Definition: htp_multipart.h:228
bstr_builder_t * part_data_pieces
Definition: htp_multipart_private.h:154
Definition: htp_multipart_private.h:76
void htp_mpart_part_destroy(htp_multipart_part_t *part, int gave_up_data)
Definition: htp_multipart.c:477
htp_status_t htp_mpartp_run_request_file_data_hook(htp_multipart_part_t *part, const unsigned char *data, size_t len)
Definition: htp_multipart.c:574
Definition: htp_multipart_private.h:59
Definition: bstr.h:57
Definition: htp_multipart_private.h:67
htp_cfg_t * cfg
Definition: htp_multipart_private.h:88
int htp_status_t
Definition: htp_core.h:46
htp_part_mode_t
Definition: htp_multipart_private.h:54
bstr * pending_header_line
Definition: htp_multipart_private.h:147
htp_multipart_part_t * htp_mpart_part_create(htp_mpartp_t *parser)
Definition: htp_multipart.c:454
size_t boundary_match_pos
Definition: htp_multipart_private.h:115
int extract_files
Definition: htp_multipart_private.h:90
int htp_mpartp_is_boundary_character(int c)
Definition: bstr_builder.h:50
int gave_up_data
Definition: htp_multipart_private.h:178
bstr_builder_t * part_header_pieces
Definition: htp_multipart_private.h:145
Definition: htp_multipart_private.h:82
enum htp_part_mode_t current_part_mode
Definition: htp_multipart_private.h:135
int(* handle_boundary)(htp_mpartp_t *mpartp)
Definition: htp_multipart_private.h:102
int extract_limit
Definition: htp_multipart_private.h:92
int file_count
Definition: htp_multipart_private.h:96
htp_status_t htp_mpart_part_finalize_data(htp_multipart_part_t *part)
Definition: htp_multipart.c:520
Definition: htp_multipart_private.h:73
int cr_aside
Definition: htp_multipart_private.h:171
Definition: htp_multipart_private.h:85
Definition: htp_multipart_private.h:64
char * extract_dir
Definition: htp_multipart_private.h:94
size_t boundary_candidate_pos
Definition: htp_multipart_private.h:160
int(* handle_data)(htp_mpartp_t *mpartp, const unsigned char *data, size_t len, int line_end)
Definition: htp_multipart_private.h:100
bstr_builder_t * boundary_pieces
Definition: htp_multipart_private.h:143