~ubuntu-branches/ubuntu/natty/libapache-mod-security/natty-updates

« back to all changes in this revision

Viewing changes to apache2/msc_multipart.h

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Gonzalez Iniesta
  • Date: 2008-08-08 13:31:56 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080808133156-6jqb24apsw787v33
Tags: 2.5.6-1
* The 'Back to the archive!' Release (Closes: #487431)
* Drop '2' from package name, now libapache-mod-security
* New upstream release
  - Includes a new licensing exception that allows binary 
    distribution with licenses not compatible with GPLv2,
    such as Apache's. See MODSECURITY_LICENSING_EXCEPTION
* Removed debian/bug and debian/rules entry to install bug
  handling when out of the archive.
* Bumped Standards-Version to 3.8.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ModSecurity for Apache 2.x, http://www.modsecurity.org/
 
3
 * Copyright (c) 2004-2008 Breach Security, Inc. (http://www.breach.com/)
 
4
 *
 
5
 * This product is released under the terms of the General Public Licence,
 
6
 * version 2 (GPLv2). Please refer to the file LICENSE (included with this
 
7
 * distribution) which contains the complete text of the licence.
 
8
 *
 
9
 * There are special exceptions to the terms and conditions of the GPL
 
10
 * as it is applied to this software. View the full text of the exception in
 
11
 * file MODSECURITY_LICENSING_EXCEPTION in the directory of this software
 
12
 * distribution.
 
13
 *
 
14
 * If any of the files related to licensing are missing or if you have any
 
15
 * other questions related to licensing please contact Breach Security, Inc.
 
16
 * directly using the email address support@breach.com.
 
17
 *
 
18
 */
 
19
#ifndef _MSC_MULTIPART_H_
 
20
#define _MSC_MULTIPART_H_
 
21
 
 
22
#define MULTIPART_BUF_SIZE              4096
 
23
 
 
24
#define MULTIPART_FORMDATA              1
 
25
#define MULTIPART_FILE                  2
 
26
 
 
27
typedef struct multipart_part multipart_part;
 
28
typedef struct multipart_data multipart_data;
 
29
 
 
30
#include "apr_general.h"
 
31
#include "apr_tables.h"
 
32
#include "modsecurity.h"
 
33
 
 
34
typedef struct value_part_t value_part_t;
 
35
struct value_part_t {
 
36
    char *data;
 
37
    long int length;
 
38
};
 
39
 
 
40
struct multipart_part {
 
41
    /* part type, can be MULTIPART_FORMDATA or MULTIPART_FILE */
 
42
    int                      type;
 
43
    /* the name */
 
44
    char                    *name;
 
45
 
 
46
    /* variables only, variable value */
 
47
    char                    *value;
 
48
    apr_array_header_t      *value_parts;
 
49
 
 
50
    /* files only, the content type (where available) */
 
51
    char                    *content_type;
 
52
 
 
53
    /* files only, the name of the temporary file holding data */
 
54
    char                    *tmp_file_name;
 
55
    int                      tmp_file_fd;
 
56
    unsigned int             tmp_file_size;
 
57
    /* files only, filename as supplied by the browser */
 
58
    char                    *filename;
 
59
 
 
60
    char                    *last_header_name;
 
61
    apr_table_t             *headers;
 
62
 
 
63
    unsigned int             offset;
 
64
    unsigned int             length;
 
65
};
 
66
 
 
67
struct multipart_data {
 
68
    /* this array keeps parts */
 
69
    apr_array_header_t      *parts;
 
70
 
 
71
    /* mime boundary used to detect when
 
72
     * parts end and begin
 
73
     */
 
74
    char                    *boundary;
 
75
    int                      boundary_count;
 
76
 
 
77
    /* internal buffer and other variables
 
78
     * used while parsing
 
79
     */
 
80
    char                     buf[MULTIPART_BUF_SIZE + 2];
 
81
    int                      buf_contains_line;
 
82
    char                    *bufptr;
 
83
    int                      bufleft;
 
84
 
 
85
    unsigned int             buf_offset;
 
86
 
 
87
    /* pointer that keeps track of a part while
 
88
     * it is being built
 
89
     */
 
90
    multipart_part          *mpp;
 
91
 
 
92
 
 
93
    /* part parsing state; 0 means we are reading
 
94
     * headers, 1 means we are collecting data
 
95
     */
 
96
    int                      mpp_state;
 
97
 
 
98
    /* because of the way this parsing algorithm
 
99
     * works we hold back the last two bytes of
 
100
     * each data chunk so that we can discard it
 
101
     * later if the next data chunk proves to be
 
102
     * a boundary; the first byte is an indicator
 
103
     * 0 - no content, 1 - two data bytes available
 
104
     */
 
105
    char                     reserve[4];
 
106
 
 
107
    int                      seen_data;
 
108
    int                      is_complete;
 
109
 
 
110
    int                      flag_error;
 
111
    int                      flag_data_before;
 
112
    int                      flag_data_after;
 
113
    int                      flag_header_folding;
 
114
    int                      flag_boundary_quoted;
 
115
    int                      flag_lf_line;
 
116
    int                      flag_crlf_line;
 
117
    int                      flag_unmatched_boundary;
 
118
    int                      flag_boundary_whitespace;
 
119
    int                      flag_missing_semicolon;
 
120
};
 
121
 
 
122
 
 
123
/* Functions */
 
124
 
 
125
int DSOLOCAL multipart_init(modsec_rec *msr, char **error_msg);
 
126
 
 
127
int DSOLOCAL multipart_complete(modsec_rec *msr, char **error_msg);
 
128
 
 
129
int DSOLOCAL multipart_process_chunk(modsec_rec *msr, const char *buf,
 
130
    unsigned int size, char **error_msg);
 
131
 
 
132
apr_status_t DSOLOCAL multipart_cleanup(modsec_rec *msr);
 
133
 
 
134
int DSOLOCAL multipart_get_arguments(modsec_rec *msr, char *origin, apr_table_t *arguments);
 
135
 
 
136
char DSOLOCAL *multipart_reconstruct_urlencoded_body_sanitise(modsec_rec *msr);
 
137
 
 
138
#endif