Module Name:    src
Committed By:   uwe
Date:           Sat Oct  5 19:19:52 UTC 2019

Modified Files:
        src/lib/libc/gen: getlogin.c

Log Message:
getlogin_r: use strcpy().  We check namelen before copying the result.
gcc 8 -Wstringop-overflow is uhappy when the specified bounds depend
on the length of the source and is not smart enough to see the check
we do.  Besides we don't want the padding effect of strncpy() here.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/gen/getlogin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/getlogin.c
diff -u src/lib/libc/gen/getlogin.c:1.15 src/lib/libc/gen/getlogin.c:1.16
--- src/lib/libc/gen/getlogin.c:1.15	Sun Jan 11 02:46:27 2009
+++ src/lib/libc/gen/getlogin.c	Sat Oct  5 19:19:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: getlogin.c,v 1.15 2009/01/11 02:46:27 christos Exp $	*/
+/*	$NetBSD: getlogin.c,v 1.16 2019/10/05 19:19:51 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
 #if 0
 static char sccsid[] = "@(#)getlogin.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: getlogin.c,v 1.15 2009/01/11 02:46:27 christos Exp $");
+__RCSID("$NetBSD: getlogin.c,v 1.16 2019/10/05 19:19:51 uwe Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -126,7 +126,7 @@ getlogin_r(char *name, size_t namelen)
 	if (len > namelen) {
 		rv = ERANGE;
 	} else {
-		strncpy(name, logname, len);
+		strcpy(name, logname);
 		rv = 0;
 	}
 	mutex_unlock(&logname_mutex);

Reply via email to