It is a wrapper around STRTCPY(), so use a proper name.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
if (*cons != '/') {
char *pbuf;
- STRLCPY(buf, cons);
+ STRTCPY(buf, cons);
pbuf = &buf[0];
while ((s = strtok (pbuf, ":")) != NULL) {
if (strcmp (s, tty) == 0) {
*/
-#ifndef SHADOW_INCLUDE_LIB_STRLCPY_H_
-#define SHADOW_INCLUDE_LIB_STRLCPY_H_
+#ifndef SHADOW_INCLUDE_LIB_STRTCPY_H_
+#define SHADOW_INCLUDE_LIB_STRTCPY_H_
#include <config.h>
/*
* SYNOPSIS
- * int STRLCPY(char dst[restrict], const char *restrict src);
+ * int STRTCPY(char dst[restrict], const char *restrict src);
*
* ARGUMENTS
* dst Destination buffer where to copy a string.
*/
-#define STRLCPY(dst, src) strtcpy(dst, src, SIZEOF_ARRAY(dst))
+#define STRTCPY(dst, src) strtcpy(dst, src, SIZEOF_ARRAY(dst))
inline ssize_t strtcpy(char *restrict dst, const char *restrict src,
if ('\0' == tmptty[0]) {
const char *tname = ttyname (STDIN_FILENO);
if (NULL != tname)
- STRLCPY(tmptty, tname);
+ STRTCPY(tmptty, tname);
}
if ('\0' == tmptty[0]) {
fail_exit (E_NOPERM);
}
- STRLCPY(user_name, pw->pw_name);
+ STRTCPY(user_name, pw->pw_name);
#ifdef WITH_TCB
if (shadowtcb_set_user (pw->pw_name) == SHADOWTCB_FAILURE) {
fail_exit (E_NOPERM);
exit (E_NOPERM);
}
fflg = true;
- STRLCPY(fullnm, optarg);
+ STRTCPY(fullnm, optarg);
break;
case 'h':
if (!may_change_field ('h')) {
exit (E_NOPERM);
}
hflg = true;
- STRLCPY(homeph, optarg);
+ STRTCPY(homeph, optarg);
break;
case 'o':
if (!amroot) {
_("%s: fields too long\n"), Prog);
exit (E_NOPERM);
}
- STRLCPY(slop, optarg);
+ STRTCPY(slop, optarg);
break;
case 'r':
if (!may_change_field ('r')) {
exit (E_NOPERM);
}
rflg = true;
- STRLCPY(roomno, optarg);
+ STRTCPY(roomno, optarg);
break;
case 'R': /* no-op, handled in process_root_flag () */
break;
exit (E_NOPERM);
}
wflg = true;
- STRLCPY(workph, optarg);
+ STRTCPY(workph, optarg);
break;
default:
usage (E_USAGE);
char *cp; /* temporary character pointer */
char old_gecos[BUFSIZ]; /* buffer for old GECOS fields */
- STRLCPY(old_gecos, gecos);
+ STRTCPY(old_gecos, gecos);
/*
* Now get the full name. It is the first comma separated field in
break;
case 's':
sflg = true;
- STRLCPY(loginsh, optarg);
+ STRTCPY(loginsh, optarg);
break;
default:
usage (E_USAGE);
* file, or use the value from the command line.
*/
if (!sflg) {
- STRLCPY(loginsh, pw->pw_shell);
+ STRTCPY(loginsh, pw->pw_shell);
}
/*
exit (1);
}
- STRLCPY(pass, cp);
+ STRTCPY(pass, cp);
erase_pass (cp);
cp = agetpass (_("Re-enter new password: "));
if (NULL == cp) {
if (NULL == tmptty) {
tmptty = "UNKNOWN";
}
- STRLCPY(tty, tmptty);
+ STRTCPY(tty, tmptty);
#ifndef USE_PAM
is_console = console (tty);
sizeof (loginprompt),
_("%s login: "), hostn);
} else {
- STRLCPY(loginprompt, _("login: "));
+ STRTCPY(loginprompt, _("login: "));
}
retcode = pam_set_item (pamh, PAM_USER_PROMPT, loginprompt);
pw->pw_name);
return -1;
}
- STRLCPY(orig, clear);
+ STRTCPY(orig, clear);
erase_pass (clear);
strzero (cipher);
} else {
if (warned && (strcmp (pass, cp) != 0)) {
warned = false;
}
- STRLCPY(pass, cp);
+ STRTCPY(pass, cp);
erase_pass (cp);
if (!amroot && (!obscure (orig, pass, pw) || reuse (pass, pw))) {
#ifdef HAVE_LIBCRACK_HIST
HistUpdate (pw->pw_name, crypt_passwd);
#endif /* HAVE_LIBCRACK_HIST */
- STRLCPY(crypt_passwd, cp);
+ STRTCPY(crypt_passwd, cp);
return 0;
}
* If there are no other flags, just change the password.
*/
if (!anyflag) {
- STRLCPY(crypt_passwd, cp);
+ STRTCPY(crypt_passwd, cp);
/*
* See if the user is permitted to change the password.
SYSLOG ((LOG_INFO,
"Change user from '%s' to '%s' as requested by PAM",
name, tmp_name));
- if (STRLCPY(name, tmp_name) == -1) {
+ if (STRTCPY(name, tmp_name) == -1) {
fprintf (stderr, _("Overlong user name '%s'\n"),
tmp_name);
SYSLOG ((LOG_NOTICE, "Overlong user name '%s'",
(unsigned long) caller_uid));
su_failure (caller_tty, true); /* unknown target UID*/
}
- STRLCPY(caller_name, pw->pw_name);
+ STRTCPY(caller_name, pw->pw_name);
#ifndef USE_PAM
#ifdef SU_ACCESS
}
if (optind < argc) {
- STRLCPY(name, argv[optind++]); /* use this login id */
+ STRTCPY(name, argv[optind++]); /* use this login id */
}
if ('\0' == name[0]) { /* use default user */
struct passwd *root_pw = getpwnam ("root");
#endif
exit (0);
}
- STRLCPY(pass, cp);
+ STRTCPY(pass, cp);
erase_pass (cp);
if (valid (pass, &pwent)) { /* check encrypted passwords ... */
#include "strlcpy.h"
-static void test_STRLCPY_trunc(void **state);
-static void test_STRLCPY_ok(void **state);
+static void test_STRTCPY_trunc(void **state);
+static void test_STRTCPY_ok(void **state);
int
main(void)
{
const struct CMUnitTest tests[] = {
- cmocka_unit_test(test_STRLCPY_trunc),
- cmocka_unit_test(test_STRLCPY_ok),
+ cmocka_unit_test(test_STRTCPY_trunc),
+ cmocka_unit_test(test_STRTCPY_ok),
};
return cmocka_run_group_tests(tests, NULL, NULL);
static void
-test_STRLCPY_trunc(void **state)
+test_STRTCPY_trunc(void **state)
{
char buf[NITEMS("foo")];
// Test that we're not returning SIZE_MAX
- assert_true(STRLCPY(buf, "fooo") < 0);
+ assert_true(STRTCPY(buf, "fooo") < 0);
assert_string_equal(buf, "foo");
- assert_int_equal(STRLCPY(buf, "barbaz"), -1);
+ assert_int_equal(STRTCPY(buf, "barbaz"), -1);
assert_string_equal(buf, "bar");
}
static void
-test_STRLCPY_ok(void **state)
+test_STRTCPY_ok(void **state)
{
char buf[NITEMS("foo")];
- assert_int_equal(STRLCPY(buf, "foo"), strlen("foo"));
+ assert_int_equal(STRTCPY(buf, "foo"), strlen("foo"));
assert_string_equal(buf, "foo");
- assert_int_equal(STRLCPY(buf, "fo"), strlen("fo"));
+ assert_int_equal(STRTCPY(buf, "fo"), strlen("fo"));
assert_string_equal(buf, "fo");
- assert_int_equal(STRLCPY(buf, "f"), strlen("f"));
+ assert_int_equal(STRTCPY(buf, "f"), strlen("f"));
assert_string_equal(buf, "f");
- assert_int_equal(STRLCPY(buf, ""), strlen(""));
+ assert_int_equal(STRTCPY(buf, ""), strlen(""));
assert_string_equal(buf, "");
}