From owner-svn-src-stable-10@FreeBSD.ORG Sun Aug 3 01:51:49 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 22226856; Sun, 3 Aug 2014 01:51:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EF1F28C1; Sun, 3 Aug 2014 01:51:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s731pmaO012268; Sun, 3 Aug 2014 01:51:48 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s731pmvO012267; Sun, 3 Aug 2014 01:51:48 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201408030151.s731pmvO012267@svn.freebsd.org> From: Marcel Moolenaar Date: Sun, 3 Aug 2014 01:51:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r269453 - stable/10/lib/libc/gen X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Aug 2014 01:51:49 -0000 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);