contrib, lib/, src/, tests/: Use stpcpy(3) instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
c6018240f8
commit
59e5eef38f
@@ -491,12 +491,12 @@ safeget (char *buf, int maxlen)
|
||||
bad = (!isalnum (c) && (c != '_') && (c != ' '));
|
||||
*(buf++) = c;
|
||||
}
|
||||
*buf = '\0';
|
||||
stpcpy(buf, "");
|
||||
|
||||
if (bad)
|
||||
{
|
||||
printf ("\nString contained banned character. Please stick to alphanumerics.\n");
|
||||
*bstart = '\0';
|
||||
stpcpy(bstart, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
buf[len] = '\0';
|
||||
stpcpy(&buf[len], "");
|
||||
if (get_pid(buf, &pid) == -1) {
|
||||
if (log) {
|
||||
(void) fprintf (shadow_logfd,
|
||||
@@ -659,7 +659,7 @@ int commonio_open (struct commonio_db *db, int mode)
|
||||
goto cleanup_buf;
|
||||
}
|
||||
}
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
|
||||
line = strdup (buf);
|
||||
if (NULL == line) {
|
||||
|
||||
@@ -76,7 +76,7 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
|
||||
*/
|
||||
|
||||
while (fgets (buf, sizeof (buf), fp) != NULL) {
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
if (strcmp (buf, tty) == 0) {
|
||||
(void) fclose (fp);
|
||||
return true;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc/malloc.h"
|
||||
#include "alloc/x/xmalloc.h"
|
||||
@@ -563,7 +564,7 @@ static /*@null@*/char *readlink_malloc (const char *filename)
|
||||
|
||||
if ((size_t) nchars < size) { /* The buffer was large enough */
|
||||
/* readlink does not nul-terminate */
|
||||
buffer[nchars] = '\0';
|
||||
stpcpy(&buffer[nchars], "");
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ void change_field (char *buf, size_t maxsize, const char *prompt)
|
||||
if (NULL == cp) {
|
||||
return;
|
||||
}
|
||||
*cp = '\0';
|
||||
stpcpy(cp, "");
|
||||
|
||||
if ('\0' != newf[0]) {
|
||||
/*
|
||||
@@ -92,7 +92,7 @@ void change_field (char *buf, size_t maxsize, const char *prompt)
|
||||
* makes it possible to change the field to empty, by
|
||||
* entering a space. --marekm
|
||||
*/
|
||||
*strrspn(newf, " \t\n") = '\0';
|
||||
stpcpy(strrspn(newf, " \t\n"), "");
|
||||
|
||||
cp = newf;
|
||||
while (isspace (*cp)) {
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
@@ -33,10 +35,8 @@ fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f)
|
||||
ep = strrchr (cp, '\\');
|
||||
if ((NULL != ep) && (*(ep + 1) == '\n')) {
|
||||
cnt -= ep - cp;
|
||||
if (cnt > 0) {
|
||||
cp = ep;
|
||||
*cp = '\0';
|
||||
}
|
||||
if (cnt > 0)
|
||||
cp = stpcpy(ep, "");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ static int LookupWord (char *buff)
|
||||
else if (strlen (buff) == 4 && buff[3] == '.')
|
||||
{
|
||||
abbrev = true;
|
||||
buff[3] = '\0';
|
||||
stpcpy(&buff[3], "");
|
||||
}
|
||||
else
|
||||
abbrev = false;
|
||||
@@ -689,7 +689,7 @@ static int LookupWord (char *buff)
|
||||
i = strlen (buff) - 1;
|
||||
if (buff[i] == 's')
|
||||
{
|
||||
buff[i] = '\0';
|
||||
stpcpy(&buff[i], "");
|
||||
for (tp = UnitsTable; tp->name; tp++)
|
||||
if (strcmp (buff, tp->name) == 0)
|
||||
{
|
||||
@@ -723,7 +723,7 @@ static int LookupWord (char *buff)
|
||||
*p++ = *q;
|
||||
else
|
||||
i++;
|
||||
*p = '\0';
|
||||
stpcpy(p, "");
|
||||
if (0 != i)
|
||||
for (tp = TimezoneTable; NULL != tp->name; tp++)
|
||||
if (strcmp (buff, tp->name) == 0)
|
||||
@@ -772,7 +772,7 @@ yylex (void)
|
||||
for (p = buff; (c = *yyInput++, isalpha (c)) || c == '.';)
|
||||
if (p < &buff[sizeof buff - 1])
|
||||
*p++ = c;
|
||||
*p = '\0';
|
||||
stpcpy(p, "");
|
||||
yyInput--;
|
||||
return LookupWord (buff);
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ static void def_load (void)
|
||||
/*
|
||||
* Trim trailing whitespace.
|
||||
*/
|
||||
*strrspn(buf, " \t\n") = '\0';
|
||||
stpcpy(strrspn(buf, " \t\n"), "");
|
||||
|
||||
/*
|
||||
* Break the line into two fields.
|
||||
@@ -573,9 +573,9 @@ static void def_load (void)
|
||||
if (*s == '\0')
|
||||
continue; /* only 1 field?? */
|
||||
|
||||
*s++ = '\0';
|
||||
stpcpy(s++, "");
|
||||
value = stpspn(s, " \"\t"); /* next nonwhite */
|
||||
*strchrnul(value, '"') = '\0';
|
||||
stpcpy(strchrnul(value, '"'), "");
|
||||
|
||||
/*
|
||||
* Store the value in def_table.
|
||||
|
||||
@@ -91,7 +91,7 @@ void endsgent (void)
|
||||
}
|
||||
|
||||
strcpy (sgrbuf, string);
|
||||
*strchrnul(sgrbuf, '\n') = '\0';
|
||||
stpcpy(strchrnul(sgrbuf, '\n'), "");
|
||||
|
||||
/*
|
||||
* There should be exactly 4 colon separated fields. Find
|
||||
@@ -172,7 +172,7 @@ void endsgent (void)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
return (sgetsgent (buf));
|
||||
}
|
||||
return NULL;
|
||||
@@ -244,53 +244,36 @@ int putsgent (const struct sgrp *sgrp, FILE * fp)
|
||||
/*
|
||||
* Copy the group name and passwd.
|
||||
*/
|
||||
|
||||
strcpy (cp, sgrp->sg_name);
|
||||
cp += strlen (cp);
|
||||
*cp++ = ':';
|
||||
|
||||
strcpy (cp, sgrp->sg_passwd);
|
||||
cp += strlen (cp);
|
||||
*cp++ = ':';
|
||||
cp = stpcpy(stpcpy(cp, sgrp->sg_name), ":");
|
||||
cp = stpcpy(stpcpy(cp, sgrp->sg_passwd), ":");
|
||||
|
||||
/*
|
||||
* Copy the administrators, separating each from the other
|
||||
* with a ",".
|
||||
*/
|
||||
|
||||
for (i = 0; NULL != sgrp->sg_adm[i]; i++) {
|
||||
if (i > 0) {
|
||||
*cp++ = ',';
|
||||
}
|
||||
if (i > 0)
|
||||
cp = stpcpy(cp, ",");
|
||||
|
||||
strcpy (cp, sgrp->sg_adm[i]);
|
||||
cp += strlen (cp);
|
||||
cp = stpcpy(cp, sgrp->sg_adm[i]);
|
||||
}
|
||||
*cp = ':';
|
||||
cp++;
|
||||
cp = stpcpy(cp, ":");
|
||||
|
||||
/*
|
||||
* Now do likewise with the group members.
|
||||
*/
|
||||
|
||||
for (i = 0; NULL != sgrp->sg_mem[i]; i++) {
|
||||
if (i > 0) {
|
||||
*cp = ',';
|
||||
cp++;
|
||||
}
|
||||
if (i > 0)
|
||||
cp = stpcpy(cp, ",");
|
||||
|
||||
strcpy (cp, sgrp->sg_mem[i]);
|
||||
cp += strlen (cp);
|
||||
cp = stpcpy(cp, sgrp->sg_mem[i]);
|
||||
}
|
||||
*cp = '\n';
|
||||
cp++;
|
||||
*cp = '\0';
|
||||
stpcpy(cp, "\n");
|
||||
|
||||
/*
|
||||
* Output using the function which understands the line
|
||||
* continuation conventions.
|
||||
*/
|
||||
|
||||
if (fputsx (buf, fp) == EOF) {
|
||||
free (buf);
|
||||
return -1;
|
||||
|
||||
@@ -72,7 +72,7 @@ bool hushed (const char *username)
|
||||
return false;
|
||||
}
|
||||
for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
found = (strcmp (buf, pw->pw_shell) == 0) ||
|
||||
(strcmp (buf, pw->pw_name) == 0);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void login_prompt (char *name, int namesize)
|
||||
if (NULL == cp) {
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
*cp = '\0'; /* remove \n [ must be there ] */
|
||||
stpcpy(cp, ""); /* remove \n [ must be there ] */
|
||||
|
||||
/*
|
||||
* Skip leading whitespace. This makes " username" work right.
|
||||
@@ -98,7 +98,7 @@ void login_prompt (char *name, int namesize)
|
||||
|
||||
for (i = 0; i < namesize - 1 && *cp != '\0'; name[i++] = *cp++);
|
||||
|
||||
name[i] = '\0';
|
||||
stpcpy(&name[i], "");
|
||||
|
||||
/*
|
||||
* Set the SIGQUIT handler back to its original value
|
||||
|
||||
@@ -189,12 +189,10 @@ static /*@observer@*//*@null@*/const char *obscure_msg (
|
||||
|
||||
new1 = xstrdup (new);
|
||||
old1 = xstrdup (old);
|
||||
if (newlen > maxlen) {
|
||||
new1[maxlen] = '\0';
|
||||
}
|
||||
if (oldlen > maxlen) {
|
||||
old1[maxlen] = '\0';
|
||||
}
|
||||
if (newlen > maxlen)
|
||||
stpcpy(&new1[maxlen], "");
|
||||
if (oldlen > maxlen)
|
||||
stpcpy(&old1[maxlen], "");
|
||||
|
||||
msg = password_check (old1, new1, pwdp);
|
||||
|
||||
|
||||
16
lib/port.c
16
lib/port.c
@@ -152,7 +152,7 @@ again:
|
||||
* TTY devices.
|
||||
*/
|
||||
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
|
||||
port.pt_names = ttys;
|
||||
for (cp = buf, j = 0; j < PORT_TTY; j++) {
|
||||
@@ -165,12 +165,10 @@ again:
|
||||
break;
|
||||
}
|
||||
|
||||
if (',' == *cp) { /* end of current tty name */
|
||||
*cp++ = '\0';
|
||||
}
|
||||
if (',' == *cp) /* end of current tty name */
|
||||
stpcpy(cp++, "");
|
||||
}
|
||||
*cp = '\0';
|
||||
cp++;
|
||||
stpcpy(cp++, "");
|
||||
port.pt_names[j] = NULL;
|
||||
|
||||
/*
|
||||
@@ -186,8 +184,7 @@ again:
|
||||
|
||||
for (j = 1; ':' != *cp; cp++) {
|
||||
if ((',' == *cp) && (j < PORT_IDS)) {
|
||||
*cp = '\0';
|
||||
cp++;
|
||||
stpcpy(cp++, "");
|
||||
port.pt_users[j] = cp;
|
||||
j++;
|
||||
}
|
||||
@@ -201,8 +198,7 @@ again:
|
||||
goto again;
|
||||
}
|
||||
|
||||
*cp = '\0';
|
||||
cp++;
|
||||
stpcpy(cp++, "");
|
||||
|
||||
/*
|
||||
* Get the list of valid times. The times field is the third
|
||||
|
||||
@@ -141,7 +141,7 @@ restart:
|
||||
*p++ = ch;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
stpcpy(p, "");
|
||||
save_errno = errno;
|
||||
if (!(term.c_lflag & ECHO))
|
||||
(void)write(output, "\n", 1);
|
||||
|
||||
19
lib/salt.c
19
lib/salt.c
@@ -291,6 +291,7 @@ static /*@observer@*/unsigned long YESCRYPT_get_salt_cost (/*@null@*/const int *
|
||||
static /*@observer@*/void YESCRYPT_salt_cost_to_buf (char *buf, unsigned long cost)
|
||||
{
|
||||
const size_t buf_begin = strlen (buf);
|
||||
char *p;
|
||||
|
||||
/*
|
||||
* Check if the result buffer is long enough.
|
||||
@@ -302,17 +303,17 @@ static /*@observer@*/void YESCRYPT_salt_cost_to_buf (char *buf, unsigned long co
|
||||
*/
|
||||
assert (GENSALT_SETTING_SIZE > buf_begin + 4);
|
||||
|
||||
buf[buf_begin + 0] = 'j';
|
||||
p = &buf[buf_begin];
|
||||
p = stpcpy(p, "j");
|
||||
if (cost < 3) {
|
||||
buf[buf_begin + 1] = 0x36 + cost;
|
||||
*p++ = 0x36 + cost;
|
||||
} else if (cost < 6) {
|
||||
buf[buf_begin + 1] = 0x34 + cost;
|
||||
*p++ = 0x34 + cost;
|
||||
} else {
|
||||
buf[buf_begin + 1] = 0x3b + cost;
|
||||
*p++ = 0x3b + cost;
|
||||
}
|
||||
buf[buf_begin + 2] = cost >= 3 ? 'T' : '5';
|
||||
buf[buf_begin + 3] = '$';
|
||||
buf[buf_begin + 4] = '\0';
|
||||
p = stpcpy(p, (cost >= 3) ? "T" : "5");
|
||||
stpcpy(p, "$");
|
||||
}
|
||||
#endif /* USE_YESCRYPT */
|
||||
|
||||
@@ -330,7 +331,7 @@ static /*@observer@*/const char *gensalt (size_t salt_size)
|
||||
strcat (salt, l64a (csrand ()));
|
||||
} while (strlen (salt) < salt_size);
|
||||
|
||||
salt[salt_size] = '\0';
|
||||
stpcpy(&salt[salt_size], "");
|
||||
|
||||
return salt;
|
||||
}
|
||||
@@ -421,7 +422,7 @@ static /*@observer@*/const char *gensalt (size_t salt_size)
|
||||
salt_len = GENSALT_SETTING_SIZE - 1;
|
||||
rounds = 0;
|
||||
memset(result, '.', salt_len);
|
||||
result[salt_len] = '\0';
|
||||
stpcpy(&result[salt_len], "");
|
||||
}
|
||||
|
||||
char *retval = crypt_gensalt (result, rounds, NULL, 0);
|
||||
|
||||
@@ -56,7 +56,7 @@ static void read_env_file (const char *filename)
|
||||
if (NULL == cp) {
|
||||
break;
|
||||
}
|
||||
*cp = '\0';
|
||||
stpcpy(cp, "");
|
||||
|
||||
cp = buf;
|
||||
/* ignore whitespace and comments */
|
||||
@@ -78,8 +78,7 @@ static void read_env_file (const char *filename)
|
||||
continue;
|
||||
}
|
||||
/* NUL-terminate the name */
|
||||
*cp = '\0';
|
||||
cp++;
|
||||
stpcpy(cp++, "");
|
||||
val = cp;
|
||||
#if 0 /* XXX untested, and needs rewrite with fewer goto's :-) */
|
||||
/*
|
||||
@@ -112,7 +111,7 @@ static void read_env_file (const char *filename)
|
||||
goto finished;
|
||||
} else if (isspace (*cp)) {
|
||||
/* unescaped whitespace - end of string */
|
||||
*cp = '\0';
|
||||
stpcpy(cp, "");
|
||||
goto finished;
|
||||
} else {
|
||||
cp++;
|
||||
|
||||
@@ -83,7 +83,7 @@ struct group *sgetgrent (const char *buf)
|
||||
}
|
||||
}
|
||||
strcpy (grpbuf, buf);
|
||||
*strchrnul(grpbuf, '\n') = '\0';
|
||||
stpcpy(strchrnul(grpbuf, '\n'), "");
|
||||
|
||||
for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
|
||||
grpfields[i] = strsep(&cp, ":");
|
||||
|
||||
@@ -54,7 +54,7 @@ sgetspent(const char *string)
|
||||
return NULL; /* fail if too long */
|
||||
}
|
||||
strcpy (spwbuf, string);
|
||||
*strchrnul(spwbuf, '\n') = '\0';
|
||||
stpcpy(strchrnul(spwbuf, '\n'), "");
|
||||
|
||||
/*
|
||||
* Tokenize the string into colon separated fields. Allow up to
|
||||
|
||||
@@ -77,7 +77,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (strlen (string) >= sizeof spwbuf)
|
||||
return 0;
|
||||
strcpy (spwbuf, string);
|
||||
*strchrnul(spwbuf, '\n') = '\0';
|
||||
stpcpy(strchrnul(spwbuf, '\n'), "");
|
||||
|
||||
/*
|
||||
* Tokenize the string into colon separated fields. Allow up to
|
||||
@@ -202,7 +202,7 @@ struct spwd *fgetspent (FILE * fp)
|
||||
|
||||
if (fgets (buf, sizeof buf, fp) != NULL)
|
||||
{
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
return my_sgetspent (buf);
|
||||
}
|
||||
return 0;
|
||||
|
||||
18
lib/sssd.c
18
lib/sssd.c
@@ -24,7 +24,7 @@ int
|
||||
sssd_flush_cache(int dbflags)
|
||||
{
|
||||
int status, code, rv;
|
||||
int i = 0;
|
||||
char *p;
|
||||
char *sss_cache_args = NULL;
|
||||
const char *cmd = "/usr/sbin/sss_cache";
|
||||
const char *spawnedArgs[] = {"sss_cache", NULL, NULL};
|
||||
@@ -40,15 +40,13 @@ sssd_flush_cache(int dbflags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
sss_cache_args[i++] = '-';
|
||||
if (dbflags & SSSD_DB_PASSWD) {
|
||||
sss_cache_args[i++] = 'U';
|
||||
}
|
||||
if (dbflags & SSSD_DB_GROUP) {
|
||||
sss_cache_args[i++] = 'G';
|
||||
}
|
||||
sss_cache_args[i++] = '\0';
|
||||
if (i == 2) {
|
||||
p = stpcpy(sss_cache_args, "-");
|
||||
if (dbflags & SSSD_DB_PASSWD)
|
||||
stpcpy(p, "U");
|
||||
if (dbflags & SSSD_DB_GROUP)
|
||||
stpcpy(p, "G");
|
||||
|
||||
if (*p == '\0') {
|
||||
/* Neither passwd nor group, nothing to do */
|
||||
free(sss_cache_args);
|
||||
return 0;
|
||||
|
||||
@@ -135,13 +135,13 @@ static /*@null@*/ char *shadowtcb_path_rel_existing (const char *name)
|
||||
}
|
||||
free (path);
|
||||
if ((size_t)ret >= sizeof(link) - 1) {
|
||||
link[sizeof(link) - 1] = '\0';
|
||||
stpcpy(&link[sizeof(link) - 1], "");
|
||||
fprintf (shadow_logfd,
|
||||
_("%s: Suspiciously long symlink: %s\n"),
|
||||
shadow_progname, link);
|
||||
return NULL;
|
||||
}
|
||||
link[ret] = '\0';
|
||||
stpcpy(&link[ret], "");
|
||||
rval = strdup (link);
|
||||
if (NULL == rval) {
|
||||
OUT_OF_MEMORY;
|
||||
@@ -200,7 +200,7 @@ static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
|
||||
goto out_free_path;
|
||||
}
|
||||
while ((ind = strchr (ptr, '/'))) {
|
||||
*ind = '\0';
|
||||
stpcpy(ind, "");
|
||||
if (asprintf (&dir, TCB_DIR "/%s", path) == -1) {
|
||||
OUT_OF_MEMORY;
|
||||
return SHADOWTCB_FAILURE;
|
||||
@@ -266,7 +266,7 @@ static shadowtcb_status rmdir_leading (char *path)
|
||||
char *ind, *dir;
|
||||
shadowtcb_status ret = SHADOWTCB_SUCCESS;
|
||||
while ((ind = strrchr (path, '/'))) {
|
||||
*ind = '\0';
|
||||
stpcpy(ind, "");
|
||||
if (asprintf (&dir, TCB_DIR "/%s", path) == -1) {
|
||||
OUT_OF_MEMORY;
|
||||
return SHADOWTCB_FAILURE;
|
||||
|
||||
@@ -49,7 +49,7 @@ void ttytype (const char *line)
|
||||
continue;
|
||||
}
|
||||
|
||||
*strchrnul(buf, '\n') = '\0';
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
|
||||
if ( (sscanf (buf, "%1023s %1023s", type, port) == 2)
|
||||
&& (strcmp (line, port) == 0)) {
|
||||
|
||||
2
lib/tz.c
2
lib/tz.c
@@ -42,7 +42,7 @@
|
||||
|
||||
strcpy (tzbuf, def_tz);
|
||||
} else {
|
||||
*strchrnul(tzbuf, '\n') = '\0';
|
||||
stpcpy(strchrnul(tzbuf, '\n'), "");
|
||||
}
|
||||
|
||||
if (NULL != fp) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "alloc/x/xcalloc.h"
|
||||
@@ -46,7 +47,7 @@ is_my_tty(const char tty[UTX_LINESIZE])
|
||||
/* tmptty shall be bigger than full_tty */
|
||||
static char tmptty[sizeof(full_tty) + 1];
|
||||
|
||||
full_tty[0] = '\0';
|
||||
stpcpy(full_tty, "");
|
||||
if (tty[0] != '/')
|
||||
strcpy (full_tty, "/dev/");
|
||||
strncat(full_tty, tty, UTX_LINESIZE);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -139,10 +139,10 @@ test_is_valid_user_name_long(void **state)
|
||||
|
||||
memset(name, '_', max);
|
||||
|
||||
name[max] = '\0';
|
||||
stpcpy(&name[max], "");
|
||||
assert_true(false == is_valid_user_name(name));
|
||||
|
||||
name[max - 1] = '\0';
|
||||
stpcpy(&name[max - 1], "");
|
||||
assert_true(is_valid_user_name(name));
|
||||
|
||||
free(name);
|
||||
|
||||
Reference in New Issue
Block a user