From: Alejandro Colomar Date: Sun, 12 Nov 2023 13:00:47 +0000 (+0100) Subject: src/, lib/, tests/: Rename STRLCPY() to STRTCPY() X-Git-Tag: 4.15.0-rc1~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=090c019ada3dae95214682f39df868f1f8553b8c;p=thirdparty%2Fshadow.git src/, lib/, tests/: Rename STRLCPY() to STRTCPY() It is a wrapper around STRTCPY(), so use a proper name. Signed-off-by: Alejandro Colomar --- diff --git a/lib/console.c b/lib/console.c index a847720a4..9284cf638 100644 --- a/lib/console.c +++ b/lib/console.c @@ -45,7 +45,7 @@ static bool is_listed (const char *cfgin, const char *tty, bool def) if (*cons != '/') { char *pbuf; - STRLCPY(buf, cons); + STRTCPY(buf, cons); pbuf = &buf[0]; while ((s = strtok (pbuf, ":")) != NULL) { if (strcmp (s, tty) == 0) { diff --git a/lib/strlcpy.h b/lib/strlcpy.h index 36d847c44..60f44f9f1 100644 --- a/lib/strlcpy.h +++ b/lib/strlcpy.h @@ -4,8 +4,8 @@ */ -#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 @@ -20,7 +20,7 @@ /* * 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. @@ -44,7 +44,7 @@ */ -#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, diff --git a/lib/utmp.c b/lib/utmp.c index 43eb2f5df..56c6cd3fc 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -47,7 +47,7 @@ static bool is_my_tty (const char tty[UT_LINESIZE]) if ('\0' == tmptty[0]) { const char *tname = ttyname (STDIN_FILENO); if (NULL != tname) - STRLCPY(tmptty, tname); + STRTCPY(tmptty, tname); } if ('\0' == tmptty[0]) { diff --git a/src/chage.c b/src/chage.c index 6896cb15a..0ee688943 100644 --- a/src/chage.c +++ b/src/chage.c @@ -823,7 +823,7 @@ int main (int argc, char **argv) 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); diff --git a/src/chfn.c b/src/chfn.c index 242868f47..c35cae4ee 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -276,7 +276,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } fflg = true; - STRLCPY(fullnm, optarg); + STRTCPY(fullnm, optarg); break; case 'h': if (!may_change_field ('h')) { @@ -285,7 +285,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } hflg = true; - STRLCPY(homeph, optarg); + STRTCPY(homeph, optarg); break; case 'o': if (!amroot) { @@ -299,7 +299,7 @@ static void process_flags (int argc, char **argv) _("%s: fields too long\n"), Prog); exit (E_NOPERM); } - STRLCPY(slop, optarg); + STRTCPY(slop, optarg); break; case 'r': if (!may_change_field ('r')) { @@ -308,7 +308,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } rflg = true; - STRLCPY(roomno, optarg); + STRTCPY(roomno, optarg); break; case 'R': /* no-op, handled in process_root_flag () */ break; @@ -322,7 +322,7 @@ static void process_flags (int argc, char **argv) exit (E_NOPERM); } wflg = true; - STRLCPY(workph, optarg); + STRTCPY(workph, optarg); break; default: usage (E_USAGE); @@ -510,7 +510,7 @@ static void get_old_fields (const char *gecos) 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 diff --git a/src/chsh.c b/src/chsh.c index 29f8afc8c..c676f1f99 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -258,7 +258,7 @@ static void process_flags (int argc, char **argv) break; case 's': sflg = true; - STRLCPY(loginsh, optarg); + STRTCPY(loginsh, optarg); break; default: usage (E_USAGE); @@ -553,7 +553,7 @@ int main (int argc, char **argv) * file, or use the value from the command line. */ if (!sflg) { - STRLCPY(loginsh, pw->pw_shell); + STRTCPY(loginsh, pw->pw_shell); } /* diff --git a/src/gpasswd.c b/src/gpasswd.c index a8a78d859..9d972662a 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -897,7 +897,7 @@ static void change_passwd (struct group *gr) exit (1); } - STRLCPY(pass, cp); + STRTCPY(pass, cp); erase_pass (cp); cp = agetpass (_("Re-enter new password: ")); if (NULL == cp) { diff --git a/src/login.c b/src/login.c index 93fd248c1..c7572f71d 100644 --- a/src/login.c +++ b/src/login.c @@ -553,7 +553,7 @@ int main (int argc, char **argv) if (NULL == tmptty) { tmptty = "UNKNOWN"; } - STRLCPY(tty, tmptty); + STRTCPY(tty, tmptty); #ifndef USE_PAM is_console = console (tty); @@ -711,7 +711,7 @@ int main (int argc, char **argv) sizeof (loginprompt), _("%s login: "), hostn); } else { - STRLCPY(loginprompt, _("login: ")); + STRTCPY(loginprompt, _("login: ")); } retcode = pam_set_item (pamh, PAM_USER_PROMPT, loginprompt); diff --git a/src/passwd.c b/src/passwd.c index 5bcd33956..13eeb426d 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -241,7 +241,7 @@ static int new_password (const struct passwd *pw) pw->pw_name); return -1; } - STRLCPY(orig, clear); + STRTCPY(orig, clear); erase_pass (clear); strzero (cipher); } else { @@ -303,7 +303,7 @@ static int new_password (const struct passwd *pw) 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))) { @@ -360,7 +360,7 @@ static int new_password (const struct passwd *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; } @@ -1031,7 +1031,7 @@ int main (int argc, char **argv) * 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. diff --git a/src/su.c b/src/su.c index 9c577f35a..6f66b3e31 100644 --- a/src/su.c +++ b/src/su.c @@ -676,7 +676,7 @@ static /*@only@*/struct passwd * do_check_perms (void) 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'", @@ -778,7 +778,7 @@ static void save_caller_context (char **argv) (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 @@ -853,7 +853,7 @@ static void process_flags (int argc, char **argv) } 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"); diff --git a/src/sulogin.c b/src/sulogin.c index ee8c96229..8b43ee7ae 100644 --- a/src/sulogin.c +++ b/src/sulogin.c @@ -160,7 +160,7 @@ static void catch_signals (unused int sig) #endif exit (0); } - STRLCPY(pass, cp); + STRTCPY(pass, cp); erase_pass (cp); if (valid (pass, &pwent)) { /* check encrypted passwords ... */ diff --git a/tests/unit/test_strlcpy.c b/tests/unit/test_strlcpy.c index 1c8aa8f6b..0dec0b74d 100644 --- a/tests/unit/test_strlcpy.c +++ b/tests/unit/test_strlcpy.c @@ -18,16 +18,16 @@ #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); @@ -35,33 +35,33 @@ main(void) 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, ""); }