1
+
1
2
#ifndef INCLUDE_LLHTTP_H_
2
3
#define INCLUDE_LLHTTP_H_
3
4
4
- #define LLHTTP_VERSION_MAJOR 8
5
+ #define LLHTTP_VERSION_MAJOR 9
5
6
#define LLHTTP_VERSION_MINOR 1
6
7
#define LLHTTP_VERSION_PATCH 2
7
8
8
- #ifndef LLHTTP_STRICT_MODE
9
- # define LLHTTP_STRICT_MODE 0
10
- #endif
11
-
12
9
#ifndef INCLUDE_LLHTTP_ITSELF_H_
13
10
#define INCLUDE_LLHTTP_ITSELF_H_
14
11
#ifdef __cplusplus
@@ -33,7 +30,7 @@ struct llhttp__internal_s {
33
30
uint8_t http_major ;
34
31
uint8_t http_minor ;
35
32
uint8_t header_state ;
36
- uint8_t lenient_flags ;
33
+ uint16_t lenient_flags ;
37
34
uint8_t upgrade ;
38
35
uint8_t finish ;
39
36
uint16_t flags ;
@@ -50,6 +47,7 @@ int llhttp__internal_execute(llhttp__internal_t* s, const char* p, const char* e
50
47
#endif
51
48
#endif /* INCLUDE_LLHTTP_ITSELF_H_ */
52
49
50
+
53
51
#ifndef LLLLHTTP_C_HEADERS_
54
52
#define LLLLHTTP_C_HEADERS_
55
53
#ifdef __cplusplus
@@ -114,7 +112,12 @@ enum llhttp_lenient_flags {
114
112
LENIENT_CHUNKED_LENGTH = 0x2 ,
115
113
LENIENT_KEEP_ALIVE = 0x4 ,
116
114
LENIENT_TRANSFER_ENCODING = 0x8 ,
117
- LENIENT_VERSION = 0x10
115
+ LENIENT_VERSION = 0x10 ,
116
+ LENIENT_DATA_AFTER_CLOSE = 0x20 ,
117
+ LENIENT_OPTIONAL_LF_AFTER_CR = 0x40 ,
118
+ LENIENT_OPTIONAL_CRLF_AFTER_CHUNK = 0x80 ,
119
+ LENIENT_OPTIONAL_CR_BEFORE_LF = 0x100 ,
120
+ LENIENT_SPACES_AFTER_CHUNK_SIZE = 0x200
118
121
};
119
122
typedef enum llhttp_lenient_flags llhttp_lenient_flags_t ;
120
123
@@ -534,6 +537,7 @@ typedef enum llhttp_status llhttp_status_t;
534
537
#endif
535
538
#endif /* LLLLHTTP_C_HEADERS_ */
536
539
540
+
537
541
#ifndef INCLUDE_LLHTTP_API_H_
538
542
#define INCLUDE_LLHTTP_API_H_
539
543
#ifdef __cplusplus
@@ -759,7 +763,8 @@ const char* llhttp_status_name(llhttp_status_t status);
759
763
* `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when
760
764
* lenient parsing is "on".
761
765
*
762
- * **(USE AT YOUR OWN RISK)**
766
+ * **Enabling this flag can pose a security issue since you will be exposed to
767
+ * request smuggling attacks. USE WITH CAUTION!**
763
768
*/
764
769
LLHTTP_EXPORT
765
770
void llhttp_set_lenient_headers (llhttp_t * parser , int enabled );
@@ -773,7 +778,8 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
773
778
* request smuggling, but may be less desirable for small number of cases
774
779
* involving legacy servers.
775
780
*
776
- * **(USE AT YOUR OWN RISK)**
781
+ * **Enabling this flag can pose a security issue since you will be exposed to
782
+ * request smuggling attacks. USE WITH CAUTION!**
777
783
*/
778
784
LLHTTP_EXPORT
779
785
void llhttp_set_lenient_chunked_length (llhttp_t * parser , int enabled );
@@ -788,7 +794,8 @@ void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
788
794
* but might interact badly with outdated and insecure clients. With this flag
789
795
* the extra request/response will be parsed normally.
790
796
*
791
- * **(USE AT YOUR OWN RISK)**
797
+ * **Enabling this flag can pose a security issue since you will be exposed to
798
+ * poisoning attacks. USE WITH CAUTION!**
792
799
*/
793
800
LLHTTP_EXPORT
794
801
void llhttp_set_lenient_keep_alive (llhttp_t * parser , int enabled );
@@ -802,14 +809,90 @@ void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
802
809
* avoid request smuggling.
803
810
* With this flag the extra value will be parsed normally.
804
811
*
805
- * **(USE AT YOUR OWN RISK)**
812
+ * **Enabling this flag can pose a security issue since you will be exposed to
813
+ * request smuggling attacks. USE WITH CAUTION!**
806
814
*/
807
815
LLHTTP_EXPORT
808
816
void llhttp_set_lenient_transfer_encoding (llhttp_t * parser , int enabled );
809
817
818
+ /* Enables/disables lenient handling of HTTP version.
819
+ *
820
+ * Normally `llhttp` would error when the HTTP version in the request or status line
821
+ * is not `0.9`, `1.0`, `1.1` or `2.0`.
822
+ * With this flag the invalid value will be parsed normally.
823
+ *
824
+ * **Enabling this flag can pose a security issue since you will allow unsupported
825
+ * HTTP versions. USE WITH CAUTION!**
826
+ */
827
+ LLHTTP_EXPORT
828
+ void llhttp_set_lenient_version (llhttp_t * parser , int enabled );
829
+
830
+ /* Enables/disables lenient handling of additional data received after a message ends
831
+ * and keep-alive is disabled.
832
+ *
833
+ * Normally `llhttp` would error when additional unexpected data is received if the message
834
+ * contains the `Connection` header with `close` value.
835
+ * With this flag the extra data will discarded without throwing an error.
836
+ *
837
+ * **Enabling this flag can pose a security issue since you will be exposed to
838
+ * poisoning attacks. USE WITH CAUTION!**
839
+ */
840
+ LLHTTP_EXPORT
841
+ void llhttp_set_lenient_data_after_close (llhttp_t * parser , int enabled );
842
+
843
+ /* Enables/disables lenient handling of incomplete CRLF sequences.
844
+ *
845
+ * Normally `llhttp` would error when a CR is not followed by LF when terminating the
846
+ * request line, the status line, the headers or a chunk header.
847
+ * With this flag only a CR is required to terminate such sections.
848
+ *
849
+ * **Enabling this flag can pose a security issue since you will be exposed to
850
+ * request smuggling attacks. USE WITH CAUTION!**
851
+ */
852
+ LLHTTP_EXPORT
853
+ void llhttp_set_lenient_optional_lf_after_cr (llhttp_t * parser , int enabled );
854
+
855
+ /*
856
+ * Enables/disables lenient handling of line separators.
857
+ *
858
+ * Normally `llhttp` would error when a LF is not preceded by CR when terminating the
859
+ * request line, the status line, the headers, a chunk header or a chunk data.
860
+ * With this flag only a LF is required to terminate such sections.
861
+ *
862
+ * **Enabling this flag can pose a security issue since you will be exposed to
863
+ * request smuggling attacks. USE WITH CAUTION!**
864
+ */
865
+ LLHTTP_EXPORT
866
+ void llhttp_set_lenient_optional_cr_before_lf (llhttp_t * parser , int enabled );
867
+
868
+ /* Enables/disables lenient handling of chunks not separated via CRLF.
869
+ *
870
+ * Normally `llhttp` would error when after a chunk data a CRLF is missing before
871
+ * starting a new chunk.
872
+ * With this flag the new chunk can start immediately after the previous one.
873
+ *
874
+ * **Enabling this flag can pose a security issue since you will be exposed to
875
+ * request smuggling attacks. USE WITH CAUTION!**
876
+ */
877
+ LLHTTP_EXPORT
878
+ void llhttp_set_lenient_optional_crlf_after_chunk (llhttp_t * parser , int enabled );
879
+
880
+ /* Enables/disables lenient handling of spaces after chunk size.
881
+ *
882
+ * Normally `llhttp` would error when after a chunk size is followed by one or more
883
+ * spaces are present instead of a CRLF or `;`.
884
+ * With this flag this check is disabled.
885
+ *
886
+ * **Enabling this flag can pose a security issue since you will be exposed to
887
+ * request smuggling attacks. USE WITH CAUTION!**
888
+ */
889
+ LLHTTP_EXPORT
890
+ void llhttp_set_lenient_spaces_after_chunk_size (llhttp_t * parser , int enabled );
891
+
810
892
#ifdef __cplusplus
811
893
} /* extern "C" */
812
894
#endif
813
895
#endif /* INCLUDE_LLHTTP_API_H_ */
814
896
897
+
815
898
#endif /* INCLUDE_LLHTTP_H_ */
0 commit comments