1 /* Reduced from haproxy-2.7.1: src/tcpcheck.c. */
3 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
5 typedef __SIZE_TYPE__
size_t;
7 #include "../../gcc.dg/analyzer/analyzer-decls.h"
10 extern void *calloc(size_t __nmemb
, size_t __size
)
11 __attribute__((__nothrow__
, __leaf__
)) __attribute__((__malloc__
))
12 __attribute__((__alloc_size__(1, 2)));
13 extern char *strdup(const char *__s
) __attribute__((__nothrow__
, __leaf__
))
14 __attribute__((__malloc__
)) __attribute__((__nonnull__(1)));
15 extern char *strstr(const char *__haystack
, const char *__needle
)
16 __attribute__((__nothrow__
, __leaf__
)) __attribute__((__pure__
))
17 __attribute__((__nonnull__(1, 2)));
18 extern size_t strlen(const char *__s
) __attribute__((__nothrow__
, __leaf__
))
19 __attribute__((__pure__
)) __attribute__((__nonnull__(1)));
35 static inline int isttest(const struct ist ist
) { return ist
.ptr
!= NULL
; }
40 } __attribute__((packed
));
43 enum http_meth_t meth
;
46 enum tcpcheck_send_type
{
50 enum tcpcheck_rule_type
{
54 struct tcpcheck_http_hdr
{
59 struct tcpcheck_send
{
60 enum tcpcheck_send_type type
;
65 struct http_meth meth
;
76 struct tcpcheck_rule
{
78 enum tcpcheck_rule_type action
;
82 struct tcpcheck_send send
;
86 enum http_meth_t
find_http_meth(const char *str
, const int len
);
87 void free_tcpcheck(struct tcpcheck_rule
*rule
, int in_pool
);
88 void free_tcpcheck_http_hdr(struct tcpcheck_http_hdr
*hdr
);
91 char *__x = (char *) ((void *)(str)); \
94 .len = __builtin_constant_p(str) ? \
95 ((void *)str == (void *)0) ? 0 : \
96 __builtin_strlen(__x) : \
99 if (__x) for (__l--; __x[++__l]; ) ; \
105 struct tcpcheck_rule
*proxy_parse_httpchk_req(char **args
, int cur_arg
,
106 struct proxy
*px
, char **errmsg
) {
107 struct tcpcheck_rule
*chk
= NULL
;
108 struct tcpcheck_http_hdr
*hdr
= NULL
;
109 char *meth
= NULL
, *uri
= NULL
, *vsn
= NULL
;
112 hdrs
= (*args
[cur_arg
+ 2] ? strstr(args
[cur_arg
+ 2], "\r\n") : NULL
);
113 body
= (*args
[cur_arg
+ 2] ? strstr(args
[cur_arg
+ 2], "\r\n\r\n") : NULL
);
119 chk
= (struct tcpcheck_rule
*) calloc(1, sizeof(*chk
));
124 chk
->action
= TCPCHK_ACT_SEND
;
125 chk
->send
.type
= TCPCHK_SEND_HTTP
;
126 chk
->send
.http
.flags
|= 0x0004;
127 chk
->send
.http
.meth
.meth
= HTTP_METH_OPTIONS
;
128 ((&chk
->send
.http
.hdrs
)->n
= (&chk
->send
.http
.hdrs
)->p
=
129 (&chk
->send
.http
.hdrs
));
131 if (*args
[cur_arg
]) {
132 if (!*args
[cur_arg
+ 1])
135 meth
= args
[cur_arg
];
137 if (*args
[cur_arg
+ 1])
138 uri
= args
[cur_arg
+ 1];
139 if (*args
[cur_arg
+ 2])
140 vsn
= args
[cur_arg
+ 2];
142 if (meth
) { /* { dg-bogus "check of 'meth' for NULL after already dereferencing it" } */
143 chk
->send
.http
.meth
.meth
= find_http_meth(meth
, strlen(meth
));
144 chk
->send
.http
.meth
.str
.area
= strdup(meth
);
145 chk
->send
.http
.meth
.str
.data
= strlen(meth
);
146 if (!chk
->send
.http
.meth
.str
.area
) {
152 chk
->send
.http
.uri
= ist(strdup(uri
));
153 if (!isttest(chk
->send
.http
.uri
)) {
158 if (vsn
) { /* { dg-bogus "check of 'vsn' for NULL after already dereferencing it" } */
159 chk
->send
.http
.vsn
= ist(strdup(vsn
));
160 if (!isttest(chk
->send
.http
.vsn
)) {
168 free_tcpcheck_http_hdr(hdr
);
169 free_tcpcheck(chk
, 0);