Avoid assigning a const char * to a char *.

MFC after:	3 weeks
This commit is contained in:
Dag-Erling Smørgrav 2008-11-04 13:49:53 +00:00
parent 4a4f18ed37
commit b8a5cd86e3
2 changed files with 10 additions and 10 deletions

View File

@ -61,6 +61,8 @@ static char * internal_string = NULL;
static size_t internal_arraysz = 0; static size_t internal_arraysz = 0;
static const char ** internal_array = NULL; static const char ** internal_array = NULL;
static char path_login_conf[] = _PATH_LOGIN_CONF;
static char * static char *
allocstr(const char *str) allocstr(const char *str)
{ {
@ -215,15 +217,14 @@ login_getclassbyname(char const *name, const struct passwd *pwd)
if (dir && snprintf(userpath, MAXPATHLEN, "%s/%s", dir, if (dir && snprintf(userpath, MAXPATHLEN, "%s/%s", dir,
_FILE_LOGIN_CONF) < MAXPATHLEN) { _FILE_LOGIN_CONF) < MAXPATHLEN) {
login_dbarray[i] = userpath;
if (_secure_path(userpath, pwd->pw_uid, pwd->pw_gid) != -1) 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'? * XXX: Why to add the system database if the class is `me'?
*/ */
if (_secure_path(_PATH_LOGIN_CONF, 0, 0) != -1) if (_secure_path(path_login_conf, 0, 0) != -1)
login_dbarray[i++] = _PATH_LOGIN_CONF; login_dbarray[i++] = path_login_conf;
login_dbarray[i] = NULL; login_dbarray[i] = NULL;
memset(lc, 0, sizeof(login_cap_t)); memset(lc, 0, sizeof(login_cap_t));

View File

@ -142,14 +142,13 @@ substvar(const char * var, const struct passwd * pwd, int hlen, int pch, int nle
int tildes = 0; int tildes = 0;
int dollas = 0; int dollas = 0;
char *p; char *p;
const char *q;
if (pwd != NULL) { if (pwd != NULL) {
/* Count the number of ~'s in var to substitute */ for (q = var; *q != '\0'; ++q) {
for (p = (char *)var; (p = strchr(p, '~')) != NULL; p++) tildes += (*q == '~');
++tildes; dollas += (*q == '$');
/* Count the number of $'s in var to substitute */ }
for (p = (char *)var; (p = strchr(p, '$')) != NULL; p++)
++dollas;
} }
np = malloc(strlen(var) + (dollas * nlen) np = malloc(strlen(var) + (dollas * nlen)