Use “copy "es_BO"” in LC_TIME of es_CU, es_CL, and es_EC
[glibc.git] / sunrpc / tst-udp-error.c
bloba968d81f2973df79cc7171be431fa63e529c9c9a
1 /* Check for use-after-free in clntudp_call (bug 21115).
2 Copyright (C) 2017-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <netinet/in.h>
20 #include <rpc/clnt.h>
21 #include <rpc/svc.h>
22 #include <support/check.h>
23 #include <support/namespace.h>
24 #include <support/xsocket.h>
25 #include <unistd.h>
27 static int
28 do_test (void)
30 support_become_root ();
31 support_enter_network_namespace ();
33 /* Obtain a likely-unused port number. */
34 struct sockaddr_in sin =
36 .sin_family = AF_INET,
37 .sin_addr.s_addr = htonl (INADDR_LOOPBACK),
40 int fd = xsocket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
41 xbind (fd, (struct sockaddr *) &sin, sizeof (sin));
42 socklen_t sinlen = sizeof (sin);
43 xgetsockname (fd, (struct sockaddr *) &sin, &sinlen);
44 /* Close the socket, so that we will receive an error below. */
45 close (fd);
48 int sock = RPC_ANYSOCK;
49 CLIENT *clnt = clntudp_create
50 (&sin, 1, 2, (struct timeval) { 1, 0 }, &sock);
51 TEST_VERIFY_EXIT (clnt != NULL);
52 TEST_VERIFY (clnt_call (clnt, 3,
53 (xdrproc_t) xdr_void, NULL,
54 (xdrproc_t) xdr_void, NULL,
55 ((struct timeval) { 3, 0 }))
56 == RPC_CANTRECV);
57 clnt_destroy (clnt);
59 return 0;
62 #include <support/test-driver.c>