Bugs in glibc 2.2
H . J . Lu
hjl@lucon.org
Sat May 20 22:29:00 GMT 2000
On Sat, May 20, 2000 at 04:46:18PM -0700, H . J . Lu wrote:
> Hi,
>
> I am working on several bugs in glibc 2.2. I had an impression that
> glibc 2.2 was very unstable. I was wondering how many people were
> using glibc 2.2. To start,
>
> There are
>
> struct __res_state _res;
>
> and
>
> void
> res_close(void) {
> res_nclose(&_res);
> }
>
> void
> res_nclose(res_state statp) {
> if (statp->_sock >= 0) {
> (void) close(statp->_sock);
> statp->_sock = -1;
> statp->_flags &= ~(RES_F_VC | RES_F_CONN);
> }
> }
>
> since _res._sock is 0, close (0) is called. It is very bad
> when 0 may be a valid fd for something else. There are other
Here is the patch.
H.J.
---
2000-05-20 2000 H.J. Lu <hjl@gnu.org>
* resolv/res_libc.c (_res): Initialize _sock to -1.
Index: resolv/res_libc.c
===================================================================
RCS file: /work/cvs/gnu/glibc/resolv/res_libc.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 res_libc.c
--- resolv/res_libc.c 2000/04/29 18:47:48 1.1.1.1
+++ resolv/res_libc.c 2000/05/21 05:22:40
@@ -89,7 +89,7 @@ res_init(void) {
#undef _res
-struct __res_state _res;
+struct __res_state _res = { _sock : -1 };
struct __res_state *
More information about the Libc-hacker
mailing list