Author: marcel Date: Sun Aug 3 01:51:48 2014 New Revision: 269453 URL: http://svnweb.freebsd.org/changeset/base/269453
Log: MFC 264161: Handle the fact that the getlogin_basic() function can return a 0 status with a NULL pointer for the login name (result). Obtained from: Juniper Networks, Inc. Modified: stable/10/lib/libc/gen/getlogin.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/getlogin.c ============================================================================== --- stable/10/lib/libc/gen/getlogin.c Sun Aug 3 00:35:10 2014 (r269452) +++ stable/10/lib/libc/gen/getlogin.c Sun Aug 3 01:51:48 2014 (r269453) @@ -87,11 +87,16 @@ getlogin_r(char *logname, int namelen) char *result; int len; int status; - + + if (namelen < 1) + return (ERANGE); + logname[0] = '\0'; + THREAD_LOCK(); result = getlogin_basic(&status); - if (status == 0) { - if ((len = strlen(result) + 1) > namelen) + if (status == 0 && result != NULL) { + len = strlen(result) + 1; + if (len > namelen) status = ERANGE; else strncpy(logname, result, len); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"