From 4ade91e4d7c33984b8cb16f9d4edc9d0e7636ba1 Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Wed, 23 Jan 2002 21:02:42 +0000 Subject: _THREAD_PRIVATE_MUTEX_UNLOCK() on error before returning; millert@ ok. --- lib/libc/gen/getlogin.c | 6 ++++-- 1 file 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 @@ -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; -- cgit v1.2.3