diff options
author | 2015-06-07 10:57:02 +0000 | |
---|---|---|
committer | 2015-06-07 10:57:02 +0000 | |
commit | 7184d24a07df16085b560f362e87bc9c9ec5004f (patch) | |
tree | 2e88f79698b8e9e9e3bdb1bcc6adf16929deab5d /pw/pw_user.c | |
parent | 89eb7d62df9bb34b2755c48f7bd74e9335c29151 (diff) | |
download | pw-darwin-7184d24a07df16085b560f362e87bc9c9ec5004f.tar.gz pw-darwin-7184d24a07df16085b560f362e87bc9c9ec5004f.tar.zst pw-darwin-7184d24a07df16085b560f362e87bc9c9ec5004f.zip |
Instead of always casting the pw_checkname input to u_char * and casting it back
to char *, change pw_checkname to directly take char * in input
Diffstat (limited to 'pw/pw_user.c')
-rw-r--r-- | pw/pw_user.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c index cb4c3de..3880c42 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -263,7 +263,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) } } if ((arg = getarg(args, 'L')) != NULL) - cnf->default_class = pw_checkname((u_char *)arg->val, 0); + cnf->default_class = pw_checkname(arg->val, 0); if ((arg = getarg(args, 'G')) != NULL && arg->val) { int i = 0; @@ -323,7 +323,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) } if ((a_name = getarg(args, 'n')) != NULL) - pwd = GETPWNAM(pw_checkname((u_char *)a_name->val, 0)); + pwd = GETPWNAM(pw_checkname(a_name->val, 0)); a_uid = getarg(args, 'u'); if (a_uid == NULL) { @@ -510,7 +510,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if ((arg = getarg(args, 'l')) != NULL) { if (strcmp(pwd->pw_name, "root") == 0) errx(EX_DATAERR, "can't rename `root' account"); - pwd->pw_name = pw_checkname((u_char *)arg->val, 0); + pwd->pw_name = pw_checkname(arg->val, 0); edited = 1; } @@ -648,7 +648,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) * Shared add/edit code */ if ((arg = getarg(args, 'c')) != NULL) { - char *gecos = pw_checkname((u_char *)arg->val, 1); + char *gecos = pw_checkname(arg->val, 1); if (strcmp(pwd->pw_gecos, gecos) != 0) { pwd->pw_gecos = gecos; edited = 1; @@ -1239,11 +1239,11 @@ print_user(struct passwd * pwd, int pretty, int v7) return EXIT_SUCCESS; } -char * -pw_checkname(u_char *name, int gecos) +char * +pw_checkname(char *name, int gecos) { char showch[8]; - u_char const *badchars, *ch, *showtype; + const char *badchars, *ch, *showtype; int reject; ch = name; @@ -1294,7 +1294,8 @@ pw_checkname(u_char *name, int gecos) if (!gecos && (ch - name) > LOGNAMESIZE) errx(EX_DATAERR, "name too long `%s' (max is %d)", name, LOGNAMESIZE); - return (char *)name; + + return (name); } |