contrib, lib/, src/, tests/: Use stpcpy(3) instead of its pattern

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-05-19 01:53:12 +02:00
committed by Serge Hallyn
parent c6018240f8
commit 59e5eef38f
34 changed files with 104 additions and 132 deletions
+2 -2
View File
@@ -462,7 +462,7 @@ int main (int argc, char **argv)
line++;
cp = strrchr (buf, '\n');
if (NULL != cp) {
*cp = '\0';
stpcpy(cp, "");
} else {
fprintf (stderr, _("%s: line %d: line too long\n"),
Prog, line);
@@ -482,7 +482,7 @@ int main (int argc, char **argv)
name = buf;
cp = strchr (name, ':');
if (NULL != cp) {
*cp = '\0';
stpcpy(cp, "");
cp++;
} else {
fprintf (stderr,
+2 -3
View File
@@ -503,7 +503,7 @@ int main (int argc, char **argv)
line++;
cp = strrchr (buf, '\n');
if (NULL != cp) {
*cp = '\0';
stpcpy(cp, "");
} else {
if (feof (stdin) == 0) {
@@ -535,8 +535,7 @@ int main (int argc, char **argv)
name = buf;
cp = strchr (name, ':');
if (NULL != cp) {
*cp = '\0';
cp++;
stpcpy(cp++, "");
} else {
fprintf (stderr,
_("%s: line %d: missing new password\n"),
+1 -1
View File
@@ -431,7 +431,7 @@ static void process_flags (int argc, char **argv)
exit (E_BAD_ARG);
}
/* terminate name, point to value */
*cp++ = '\0';
stpcpy(cp++, "");
if (putdef_str (optarg, cp, NULL) < 0) {
exit (E_BAD_ARG);
}
+3 -3
View File
@@ -111,7 +111,7 @@ int login_access (const char *user, const char *from)
if (line[0] == '#') {
continue; /* comment line */
}
*strrspn(line, " \t\n") = '\0';
stpcpy(strrspn(line, " \t\n"), "");
if (line[0] == '\0') { /* skip blank lines */
continue;
}
@@ -182,7 +182,7 @@ static char *myhostname (void)
if (name[0] == '\0') {
gethostname (name, sizeof (name));
name[MAXHOSTNAMELEN] = '\0';
stpcpy(&name[MAXHOSTNAMELEN], "");
}
return (name);
}
@@ -222,7 +222,7 @@ static bool user_match (const char *tok, const char *string)
*/
at = strchr (tok + 1, '@');
if (NULL != at) { /* split user@host pattern */
*at = '\0';
stpcpy(at, "");
return ( user_match (tok, string)
&& from_match (at + 1, myhostname ()));
#if HAVE_INNETGR
+4 -5
View File
@@ -200,11 +200,10 @@ main(int argc, char **argv)
}
/* child */
if (strncmp (ut->ut_line, "/dev/", 5) != 0) {
strcpy (tty_name, "/dev/");
} else {
tty_name[0] = '\0';
}
if (strncmp(ut->ut_line, "/dev/", 5) != 0)
strcpy(tty_name, "/dev/");
else
strcpy(tty_name, "");
STRNCAT(tty_name, ut->ut_line);
#ifndef O_NOCTTY
+2 -3
View File
@@ -1107,9 +1107,8 @@ int main (int argc, char **argv)
Prog, line);
fail_exit (EXIT_FAILURE);
}
if (cp != NULL) {
*cp = '\0';
}
if (cp != NULL)
stpcpy(cp, "");
/*
* Break the string into fields and screw around with them.
+3 -4
View File
@@ -226,7 +226,7 @@ static int new_password (const struct passwd *pw)
erase_pass (clear);
strzero (cipher);
} else {
orig[0] = '\0';
strcpy(orig, "");
}
/*
@@ -514,9 +514,8 @@ static char *update_crypt_pw (char *cp)
}
}
if (dflg) {
*cp = '\0';
}
if (dflg)
strcpy(cp, "");
if (uflg && *cp == '!') {
if (cp[1] == '\0') {
+1 -1
View File
@@ -81,7 +81,7 @@ int check_su_auth (const char *actual_id,
continue;
}
*strrspn(temp, " \t\n") = '\0';
stpcpy(strrspn(temp, " \t\n"), "");
posn = 0;
while (temp[posn] == ' ' || temp[posn] == '\t')
+5 -6
View File
@@ -361,7 +361,7 @@ static void get_defaults (void)
* values are used, everything else can be ignored.
*/
while (fgets (buf, sizeof buf, fp) == buf) {
*strchrnul(buf, '\n') = '\0';
stpcpy(strchrnul(buf, '\n'), "");
cp = strchr (buf, '=');
if (NULL == cp) {
@@ -605,7 +605,7 @@ static int set_defaults (void)
while (fgets (buf, sizeof buf, ifp) == buf) {
cp = strrchr (buf, '\n');
if (NULL != cp) {
*cp = '\0';
stpcpy(cp, "");
} else {
/* A line which does not end with \n is only valid
* at the end of the file.
@@ -1358,8 +1358,7 @@ static void process_flags (int argc, char **argv)
exit (E_BAD_ARG);
}
/* terminate name, point to value */
*cp = '\0';
cp++;
stpcpy(cp++, "");
if (putdef_str (optarg, cp, NULL) < 0) {
exit (E_BAD_ARG);
}
@@ -2223,7 +2222,7 @@ static void create_home (void)
if (access (prefix_user_home, F_OK) == 0)
return;
path[0] = '\0';
strcpy(path, "");
bhome = strdup(prefix_user_home);
if (!bhome) {
fprintf(stderr,
@@ -2269,7 +2268,7 @@ static void create_home (void)
Prog, path);
fail_exit(E_HOMEDIR);
}
btrfs_check[strlen(path) - strlen(cp) - 1] = '\0';
stpcpy(&btrfs_check[strlen(path) - strlen(cp) - 1], "");
if (is_btrfs(btrfs_check) <= 0) {
fprintf(stderr,
_("%s: home directory \"%s\" must be mounted on BTRFS\n"),