Skip several analyzer socket tests on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / null-deref-pr108251-smp_fetch_ssl_fc_has_early.c
blobc5f1fa42e6f193fe6a0374e040945e1d7846aef1
1 /* Reduced from haproxy's src/ssl_sample.c */
3 /* { dg-require-effective-target ptr_eq_long } */
4 /* { dg-additional-options "-Wno-analyzer-symbol-too-complex" } */
6 union sample_value {
7 long long int sint;
8 /* [...snip...] */
9 };
11 struct sample_data {
12 int type;
13 union sample_value u;
16 enum {
17 /* [...snip...] */
18 SMP_T_BOOL,
19 /* [...snip...] */
21 struct sample {
22 unsigned int flags;
23 struct sample_data data;
24 /* [...snip...] */
25 struct session *sess;
26 struct stream *strm;
27 /* [...snip...] */
29 struct arg {
30 /* [...snip...] */
32 enum obj_type {
33 OBJ_TYPE_NONE = 0,
34 /* [...snip...] */
35 OBJ_TYPE_CONN,
36 /* [...snip...] */
37 OBJ_TYPE_CHECK,
38 OBJ_TYPE_ENTRIES
40 enum {
41 /* [...snip...] */
42 CO_FL_EARLY_SSL_HS = 0x00004000,
43 CO_FL_EARLY_DATA = 0x00008000,
44 /* [...snip...] */
45 CO_FL_SSL_WAIT_HS = 0x08000000,
46 /* [...snip...] */
48 struct connection {
49 enum obj_type obj_type;
50 unsigned char err_code;
51 /* [...snip...] */
52 unsigned int flags;
53 /* [...snip...] */
56 static inline enum obj_type obj_type(const enum obj_type *t)
58 if (!t || *t >= OBJ_TYPE_ENTRIES)
59 return OBJ_TYPE_NONE;
60 return *t;
62 static inline struct connection *__objt_conn(enum obj_type *t)
64 return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type)));
66 static inline struct connection *objt_conn(enum obj_type *t)
68 if (!t || *t != OBJ_TYPE_CONN)
69 return (struct connection *) ((void *)0);
70 return __objt_conn(t);
72 struct session {
73 /* [...snip...] */
74 enum obj_type *origin;
75 /* [...snip...] */
77 typedef struct ssl_st SSL;
78 SSL *ssl_sock_get_ssl_object(struct connection *conn);
80 /*****************************************************************************/
82 int
83 smp_fetch_ssl_fc_has_early(const struct arg *args, struct sample *smp, const char *kw, void *Private)
85 SSL *ssl;
86 struct connection *conn;
88 conn = objt_conn(smp->sess->origin);
89 ssl = ssl_sock_get_ssl_object(conn);
90 if (!ssl)
91 return 0;
93 smp->flags = 0;
94 smp->data.type = SMP_T_BOOL;
95 smp->data.u.sint = ((conn->flags & CO_FL_EARLY_DATA) && /* { dg-bogus "dereference of NULL 'conn'" "PR analyzer/108251" { xfail *-*-*} } */
96 (conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_SSL_WAIT_HS))) ? 1 : 0;
98 return 1;