summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-01-23 21:02:42 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-01-23 21:02:42 +0000
commit4ade91e4d7c33984b8cb16f9d4edc9d0e7636ba1 (patch)
treebd1d9e86401c9425b4c45ef06050ef48369f1847 /lib
parent3920fff77132c7704a3a0c01a12dc008e80448c0 (diff)
_THREAD_PRIVATE_MUTEX_UNLOCK() on error before returning; millert@ ok.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/getlogin.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c
index ae2a63b778a..e8094863ec3 100644
--- a/lib/libc/gen/getlogin.c
+++ b/lib/libc/gen/getlogin.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getlogin.c,v 1.5 2000/01/06 08:24:16 d Exp $";
+static char rcsid[] = "$OpenBSD: getlogin.c,v 1.6 2002/01/23 21:02:41 fgsch Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -86,8 +86,10 @@ getlogin_r(name, namelen)
logname[MAXLOGNAME] = '\0'; /* paranoia */
}
logname_size = strlen(logname) + 1;
- if (namelen < logname_size)
+ if (namelen < logname_size) {
+ _THREAD_PRIVATE_MUTEX_UNLOCK(logname);
return ERANGE;
+ }
memcpy(name, logname, logname_size);
_THREAD_PRIVATE_MUTEX_UNLOCK(logname);
return 0;