This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
getXXent.c endless loop
- To: libc-hacker@cygnus.com
- Subject: getXXent.c endless loop
- From: Thorsten Kukuk <kukuk@weber-eb.uni-paderborn.de>
- Date: Sat, 8 Aug 1998 20:27:17 +0200
- Reply-To: kukuk@weber-eb.uni-paderborn.de
Hello,
In nss/getXXent.c, there is a bug: If we need once more memory, errno is set
to ERANGE., but never set back. If we have read the last entry, errno is
ERANGE, and we will allocate all available memory.
Thorsten
--
Thorsten Kukuk kukuk@vt.uni-paderborn.de
http://www-vt.uni-paderborn.de/~kukuk
Linux is like a Vorlon. It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.
1998-08-08 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nss/getXXent.c: Reset errno to avoid endless loop.
diff -u -r --new-file glibc-2.0.95/nss/getXXent.c libc-work/nss/getXXent.c
--- glibc-2.0.95/nss/getXXent.c Tue Apr 21 00:15:49 1998
+++ libc-work/nss/getXXent.c Sat Aug 8 19:31:26 1998
@@ -81,6 +81,7 @@
buffer = malloc (buffer_size);
}
+ save = errno;
while (buffer != NULL
&& INTERNAL (REENTRANT_GETNAME) (&resbuf, buffer, buffer_size, &result
H_ERRNO_VAR) != 0
@@ -96,10 +97,9 @@
{
/* We are out of memory. Free the current buffer so that the
process gets a chance for a normal termination. */
- save = errno;
free (buffer);
- __set_errno (save);
}
+ __set_errno (save);
buffer = new_buf;
}