]>
Commit | Line | Data |
---|---|---|
6da48ca0 | 1 | /* Miscellaneous definitions for libresolv. |
04277e02 | 2 | Copyright (C) 1995-2019 Free Software Foundation, Inc. |
6da48ca0 FW |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
a2e1b046 | 19 | /* |
b43b13ac | 20 | * Copyright (c) 1995-1999 by Internet Software Consortium. |
df21c858 | 21 | * |
a2e1b046 RM |
22 | * Permission to use, copy, modify, and distribute this software for any |
23 | * purpose with or without fee is hereby granted, provided that the above | |
b43b13ac | 24 | * copyright notice and this permission notice appear in all copies. |
df21c858 | 25 | * |
b43b13ac UD |
26 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS |
27 | * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | |
28 | * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE | |
29 | * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |
a2e1b046 RM |
30 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
31 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | |
32 | * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
33 | * SOFTWARE. | |
a2e1b046 RM |
34 | */ |
35 | ||
a2e1b046 | 36 | #include <resolv.h> |
b43b13ac | 37 | |
6da48ca0 FW |
38 | /* This function belongs to libresolv, which is why it is not included |
39 | in res-close.c. */ | |
b43b13ac | 40 | void |
6da48ca0 FW |
41 | __res_close (void) |
42 | { | |
43 | /* Some programs call res_close before res_init. Since _res._vcsock | |
44 | isn't explicitly initialized, these means that we could call | |
45 | close (0), which might lead to some security problems. Therefore | |
46 | we check if res_init was called before by looking at the RES_INIT | |
47 | bit in _res.options. If it hasn't been set we bail out | |
48 | early. */ | |
49 | if ((_res.options & RES_INIT) == 0) | |
50 | return; | |
51 | /* We don't free the name server addresses because we never did it | |
52 | and it would be done implicitly on shutdown. */ | |
53 | __res_iclose (&_res, false); | |
b43b13ac | 54 | } |