From owner-svn-src-head@FreeBSD.ORG Tue Nov 4 13:49:54 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5890C106571A; Tue, 4 Nov 2008 13:49:54 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4688D8FC16; Tue, 4 Nov 2008 13:49:54 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mA4DnsFB098252; Tue, 4 Nov 2008 13:49:54 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA4DnsrB098250; Tue, 4 Nov 2008 13:49:54 GMT (envelope-from des@svn.freebsd.org) Message-Id: <200811041349.mA4DnsrB098250@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 4 Nov 2008 13:49:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r184633 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Nov 2008 13:49:54 -0000 Author: des Date: Tue Nov 4 13:49:53 2008 New Revision: 184633 URL: http://svn.freebsd.org/changeset/base/184633 Log: Avoid assigning a const char * to a char *. MFC after: 3 weeks Modified: head/lib/libutil/login_cap.c head/lib/libutil/login_class.c Modified: head/lib/libutil/login_cap.c ============================================================================== --- head/lib/libutil/login_cap.c Tue Nov 4 13:49:18 2008 (r184632) +++ head/lib/libutil/login_cap.c Tue Nov 4 13:49:53 2008 (r184633) @@ -61,6 +61,8 @@ static char * internal_string = NULL; static size_t internal_arraysz = 0; static const char ** internal_array = NULL; +static char path_login_conf[] = _PATH_LOGIN_CONF; + static char * allocstr(const char *str) { @@ -215,15 +217,14 @@ login_getclassbyname(char const *name, c if (dir && snprintf(userpath, MAXPATHLEN, "%s/%s", dir, _FILE_LOGIN_CONF) < MAXPATHLEN) { - login_dbarray[i] = userpath; if (_secure_path(userpath, pwd->pw_uid, pwd->pw_gid) != -1) - i++; /* only use 'secure' data */ + login_dbarray[i++] = userpath; } /* * XXX: Why to add the system database if the class is `me'? */ - if (_secure_path(_PATH_LOGIN_CONF, 0, 0) != -1) - login_dbarray[i++] = _PATH_LOGIN_CONF; + if (_secure_path(path_login_conf, 0, 0) != -1) + login_dbarray[i++] = path_login_conf; login_dbarray[i] = NULL; memset(lc, 0, sizeof(login_cap_t)); Modified: head/lib/libutil/login_class.c ============================================================================== --- head/lib/libutil/login_class.c Tue Nov 4 13:49:18 2008 (r184632) +++ head/lib/libutil/login_class.c Tue Nov 4 13:49:53 2008 (r184633) @@ -142,14 +142,13 @@ substvar(const char * var, const struct int tildes = 0; int dollas = 0; char *p; + const char *q; if (pwd != NULL) { - /* Count the number of ~'s in var to substitute */ - for (p = (char *)var; (p = strchr(p, '~')) != NULL; p++) - ++tildes; - /* Count the number of $'s in var to substitute */ - for (p = (char *)var; (p = strchr(p, '$')) != NULL; p++) - ++dollas; + for (q = var; *q != '\0'; ++q) { + tildes += (*q == '~'); + dollas += (*q == '$'); + } } np = malloc(strlen(var) + (dollas * nlen)