Tizen 2.0 Release
[external/libgnutls26.git] / tests / setcredcrash.c
1 /*
2  * Copyright (C) 2008, 2010 Free Software Foundation, Inc.
3  *
4  * Author: Simon Josefsson
5  *
6  * This file is part of GnuTLS.
7  *
8  * GnuTLS is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * GnuTLS is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with GnuTLS; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <gnutls/gnutls.h>
31
32 int
33 main (int argc, char *argv[])
34 {
35   gnutls_anon_client_credentials_t c_anoncred;
36   gnutls_session_t client;
37
38   gnutls_global_init ();
39
40   gnutls_anon_allocate_client_credentials (&c_anoncred);
41   gnutls_init (&client, GNUTLS_CLIENT);
42   gnutls_set_default_priority (client);
43
44   /* Test setting the same credential type twice.  Earlier GnuTLS had
45      a bug that crashed when this happened. */
46   gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
47   gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
48
49   gnutls_deinit (client);
50   gnutls_anon_free_client_credentials (c_anoncred);
51
52   gnutls_global_deinit ();
53
54   return 0;
55 }