large strc{py,at}_truncate -> strlc{py,at} replacement
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6984 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -119,16 +119,16 @@ setpeer(int argc, char **argv)
|
||||
/*
|
||||
* Set up defaults for FTP.
|
||||
*/
|
||||
strcpy_truncate(typename, "ascii", sizeof(typename));
|
||||
strlcpy(typename, "ascii", sizeof(typename));
|
||||
type = TYPE_A;
|
||||
curtype = TYPE_A;
|
||||
strcpy_truncate(formname, "non-print", sizeof(formname));
|
||||
strlcpy(formname, "non-print", sizeof(formname));
|
||||
form = FORM_N;
|
||||
strcpy_truncate(modename, "stream", sizeof(modename));
|
||||
strlcpy(modename, "stream", sizeof(modename));
|
||||
mode = MODE_S;
|
||||
strcpy_truncate(structname, "file", sizeof(structname));
|
||||
strlcpy(structname, "file", sizeof(structname));
|
||||
stru = STRU_F;
|
||||
strcpy_truncate(bytename, "8", sizeof(bytename));
|
||||
strlcpy(bytename, "8", sizeof(bytename));
|
||||
bytesize = 8;
|
||||
if (autologin)
|
||||
login(argv[1]);
|
||||
@@ -170,7 +170,7 @@ setpeer(int argc, char **argv)
|
||||
* for text files unless changed by the user.
|
||||
*/
|
||||
type = 0;
|
||||
strcpy_truncate(typename, "binary", sizeof(typename));
|
||||
strlcpy(typename, "binary", sizeof(typename));
|
||||
if (overbose)
|
||||
printf("Using %s mode to transfer files.\n",
|
||||
typename);
|
||||
@@ -243,7 +243,7 @@ settype(int argc, char **argv)
|
||||
else
|
||||
comret = command("TYPE %s", p->t_mode);
|
||||
if (comret == COMPLETE) {
|
||||
strcpy_truncate(typename, p->t_name, sizeof(typename));
|
||||
strlcpy(typename, p->t_name, sizeof(typename));
|
||||
curtype = type = p->t_type;
|
||||
}
|
||||
}
|
||||
@@ -784,7 +784,7 @@ remglob(char **argv, int doswitch)
|
||||
}
|
||||
if (ftemp == NULL) {
|
||||
int fd;
|
||||
strcpy_truncate(temp, _PATH_TMP_XXX, sizeof(temp));
|
||||
strlcpy(temp, _PATH_TMP_XXX, sizeof(temp));
|
||||
fd = mkstemp(temp);
|
||||
if(fd < 0){
|
||||
warn("unable to create temporary file %s", temp);
|
||||
@@ -1419,11 +1419,11 @@ quote1(char *initial, int argc, char **argv)
|
||||
int i;
|
||||
char buf[BUFSIZ]; /* must be >= sizeof(line) */
|
||||
|
||||
strcpy_truncate(buf, initial, sizeof(buf));
|
||||
strlcpy(buf, initial, sizeof(buf));
|
||||
for(i = 1; i < argc; i++) {
|
||||
if(i > 1)
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strcat_truncate(buf, argv[i], sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
strlcat(buf, argv[i], sizeof(buf));
|
||||
}
|
||||
if (command("%s", buf) == PRELIM) {
|
||||
while (getreply(0) == PRELIM)
|
||||
@@ -1575,11 +1575,11 @@ account(int argc, char **argv)
|
||||
if (argc > 1) {
|
||||
++argv;
|
||||
--argc;
|
||||
strcpy_truncate (acct, *argv, sizeof(acct));
|
||||
strlcpy (acct, *argv, sizeof(acct));
|
||||
while (argc > 1) {
|
||||
--argc;
|
||||
++argv;
|
||||
strcat_truncate(acct, *argv, sizeof(acct));
|
||||
strlcat(acct, *argv, sizeof(acct));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1691,12 +1691,12 @@ setntrans(int argc, char **argv)
|
||||
}
|
||||
ntflag++;
|
||||
code = ntflag;
|
||||
strcpy_truncate (ntin, argv[1], 17);
|
||||
strlcpy (ntin, argv[1], 17);
|
||||
if (argc == 2) {
|
||||
ntout[0] = '\0';
|
||||
return;
|
||||
}
|
||||
strcpy_truncate (ntout, argv[2], 17);
|
||||
strlcpy (ntout, argv[2], 17);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -1753,10 +1753,10 @@ setnmap(int argc, char **argv)
|
||||
cp = strchr(altarg, ' ');
|
||||
}
|
||||
*cp = '\0';
|
||||
strcpy_truncate(mapin, altarg, MaxPathLen);
|
||||
strlcpy(mapin, altarg, MaxPathLen);
|
||||
while (*++cp == ' ')
|
||||
continue;
|
||||
strcpy_truncate(mapout, cp, MaxPathLen);
|
||||
strlcpy(mapout, cp, MaxPathLen);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -2008,7 +2008,7 @@ macdef(int argc, char **argv)
|
||||
if (interactive) {
|
||||
printf("Enter macro line by line, terminating it with a null line\n");
|
||||
}
|
||||
strcpy_truncate(macros[macnum].mac_name,
|
||||
strlcpy(macros[macnum].mac_name,
|
||||
argv[1],
|
||||
sizeof(macros[macnum].mac_name));
|
||||
if (macnum == 0) {
|
||||
|
@@ -56,7 +56,7 @@ domacro(int argc, char **argv)
|
||||
code = -1;
|
||||
return;
|
||||
}
|
||||
strcpy_truncate(line2, line, sizeof(line2));
|
||||
strlcpy(line2, line, sizeof(line2));
|
||||
TOP:
|
||||
cp1 = macros[i].mac_start;
|
||||
while (cp1 != macros[i].mac_end) {
|
||||
|
@@ -75,7 +75,7 @@ hookup (const char *host, int port)
|
||||
code = -1;
|
||||
return NULL;
|
||||
}
|
||||
strcpy_truncate (hostnamebuf, hp->h_name, sizeof(hostnamebuf));
|
||||
strlcpy (hostnamebuf, hp->h_name, sizeof(hostnamebuf));
|
||||
hostname = hostnamebuf;
|
||||
af = hisctladdr->sa_family = hp->h_addrtype;
|
||||
|
||||
@@ -99,7 +99,7 @@ hookup (const char *host, int port)
|
||||
|
||||
if (inet_ntop (af, socket_get_address(hisctladdr),
|
||||
addr, sizeof(addr)) == NULL)
|
||||
strcpy_truncate (addr, "unknown address",
|
||||
strlcpy (addr, "unknown address",
|
||||
sizeof(addr));
|
||||
warn ("connect %s", addr);
|
||||
close (s);
|
||||
@@ -200,7 +200,7 @@ login (char *host)
|
||||
else
|
||||
user = tmp;
|
||||
}
|
||||
strcpy_truncate(username, user, sizeof(username));
|
||||
strlcpy(username, user, sizeof(username));
|
||||
n = command("USER %s", user);
|
||||
if (n == CONTINUE) {
|
||||
if(sec_complete)
|
||||
@@ -240,7 +240,7 @@ login (char *host)
|
||||
return (1);
|
||||
for (n = 0; n < macnum; ++n) {
|
||||
if (!strcmp("init", macros[n].mac_name)) {
|
||||
strcpy_truncate (line, "$init", sizeof (line));
|
||||
strlcpy (line, "$init", sizeof (line));
|
||||
makeargv();
|
||||
domacro(margc, margv);
|
||||
break;
|
||||
@@ -1471,7 +1471,7 @@ pswitch (int flag)
|
||||
ip->connect = connected;
|
||||
connected = op->connect;
|
||||
if (hostname) {
|
||||
strcpy_truncate (ip->name, hostname, sizeof (ip->name));
|
||||
strlcpy (ip->name, hostname, sizeof (ip->name));
|
||||
} else
|
||||
ip->name[0] = 0;
|
||||
hostname = op->name;
|
||||
@@ -1497,16 +1497,16 @@ pswitch (int flag)
|
||||
mcase = op->mcse;
|
||||
ip->ntflg = ntflag;
|
||||
ntflag = op->ntflg;
|
||||
strcpy_truncate (ip->nti, ntin, sizeof (ip->nti));
|
||||
strcpy_truncate (ntin, op->nti, 17);
|
||||
strcpy_truncate (ip->nto, ntout, sizeof (ip->nto));
|
||||
strcpy_truncate (ntout, op->nto, 17);
|
||||
strlcpy (ip->nti, ntin, sizeof (ip->nti));
|
||||
strlcpy (ntin, op->nti, 17);
|
||||
strlcpy (ip->nto, ntout, sizeof (ip->nto));
|
||||
strlcpy (ntout, op->nto, 17);
|
||||
ip->mapflg = mapflag;
|
||||
mapflag = op->mapflg;
|
||||
strcpy_truncate (ip->mi, mapin, MaxPathLen);
|
||||
strcpy_truncate (mapin, op->mi, MaxPathLen);
|
||||
strcpy_truncate (ip->mo, mapout, MaxPathLen);
|
||||
strcpy_truncate (mapout, op->mo, MaxPathLen);
|
||||
strlcpy (ip->mi, mapin, MaxPathLen);
|
||||
strlcpy (mapin, op->mi, MaxPathLen);
|
||||
strlcpy (ip->mo, mapout, MaxPathLen);
|
||||
strlcpy (mapout, op->mo, MaxPathLen);
|
||||
signal(SIGINT, oldintr);
|
||||
if (abrtflag) {
|
||||
abrtflag = 0;
|
||||
@@ -1680,7 +1680,7 @@ gunique (char *local)
|
||||
warn ("local: %s", local);
|
||||
return NULL;
|
||||
}
|
||||
strcpy_truncate (new, local, sizeof(new));
|
||||
strlcpy (new, local, sizeof(new));
|
||||
cp = new + strlen(new);
|
||||
*cp++ = '.';
|
||||
while (!d) {
|
||||
|
@@ -152,9 +152,9 @@ krb4_adat(void *app_data, void *buf, size_t len)
|
||||
memcpy(d->key, auth_dat.session, sizeof(d->key));
|
||||
des_set_key(&d->key, d->schedule);
|
||||
|
||||
strcpy_truncate(d->name, auth_dat.pname, sizeof(d->name));
|
||||
strcpy_truncate(d->instance, auth_dat.pinst, sizeof(d->instance));
|
||||
strcpy_truncate(d->realm, auth_dat.prealm, sizeof(d->instance));
|
||||
strlcpy(d->name, auth_dat.pname, sizeof(d->name));
|
||||
strlcpy(d->instance, auth_dat.pinst, sizeof(d->instance));
|
||||
strlcpy(d->realm, auth_dat.prealm, sizeof(d->instance));
|
||||
|
||||
cs = auth_dat.checksum + 1;
|
||||
{
|
||||
@@ -213,15 +213,15 @@ mk_auth(struct krb4_data *d, KTEXT adat,
|
||||
CREDENTIALS cred;
|
||||
char sname[SNAME_SZ], inst[INST_SZ], realm[REALM_SZ];
|
||||
|
||||
strcpy_truncate(sname, service, sizeof(sname));
|
||||
strcpy_truncate(inst, krb_get_phost(host), sizeof(inst));
|
||||
strcpy_truncate(realm, krb_realmofhost(host), sizeof(realm));
|
||||
strlcpy(sname, service, sizeof(sname));
|
||||
strlcpy(inst, krb_get_phost(host), sizeof(inst));
|
||||
strlcpy(realm, krb_realmofhost(host), sizeof(realm));
|
||||
ret = krb_mk_req(adat, sname, inst, realm, checksum);
|
||||
if(ret)
|
||||
return ret;
|
||||
strcpy_truncate(sname, service, sizeof(sname));
|
||||
strcpy_truncate(inst, krb_get_phost(host), sizeof(inst));
|
||||
strcpy_truncate(realm, krb_realmofhost(host), sizeof(realm));
|
||||
strlcpy(sname, service, sizeof(sname));
|
||||
strlcpy(inst, krb_get_phost(host), sizeof(inst));
|
||||
strlcpy(realm, krb_realmofhost(host), sizeof(realm));
|
||||
ret = krb_get_cred(sname, inst, realm, &cred);
|
||||
memmove(&d->key, &cred.session, sizeof(des_cblock));
|
||||
des_key_sched(&d->key, d->schedule);
|
||||
|
@@ -107,7 +107,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
pw = k_getpwuid(getuid());
|
||||
if (pw != NULL) {
|
||||
strcpy_truncate(homedir, pw->pw_dir, sizeof(homedir));
|
||||
strlcpy(homedir, pw->pw_dir, sizeof(homedir));
|
||||
home = homedir;
|
||||
}
|
||||
if (argc > 0) {
|
||||
@@ -246,7 +246,7 @@ cmdscanner(int top)
|
||||
p = readline("ftp> ");
|
||||
if(p == NULL)
|
||||
quit(0, 0);
|
||||
strcpy_truncate(line, p, sizeof(line));
|
||||
strlcpy(line, p, sizeof(line));
|
||||
add_history(p);
|
||||
free(p);
|
||||
} else{
|
||||
|
@@ -77,7 +77,7 @@ guess_domain (char *hostname, size_t sz)
|
||||
char **aliases;
|
||||
|
||||
if (gethostname (hostname, sz) < 0) {
|
||||
strcpy_truncate (hostname, "", sz);
|
||||
strlcpy (hostname, "", sz);
|
||||
return "";
|
||||
}
|
||||
dot = strchr (hostname, '.');
|
||||
@@ -90,13 +90,13 @@ guess_domain (char *hostname, size_t sz)
|
||||
|
||||
dot = strchr (he->h_name, '.');
|
||||
if (dot != NULL) {
|
||||
strcpy_truncate (hostname, he->h_name, sz);
|
||||
strlcpy (hostname, he->h_name, sz);
|
||||
return dot + 1;
|
||||
}
|
||||
for (aliases = he->h_aliases; (a = *aliases) != NULL; ++aliases) {
|
||||
dot = strchr (a, '.');
|
||||
if (dot != NULL) {
|
||||
strcpy_truncate (hostname, a, sz);
|
||||
strlcpy (hostname, a, sz);
|
||||
return dot + 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1023,7 +1023,7 @@ ftpd_getline(char *s, int n)
|
||||
cs = s;
|
||||
/* tmpline may contain saved command from urgent mode interruption */
|
||||
if(ftp_command){
|
||||
strcpy_truncate(s, ftp_command, n);
|
||||
strlcpy(s, ftp_command, n);
|
||||
if (debug)
|
||||
syslog(LOG_DEBUG, "command: %s", s);
|
||||
#ifdef XXX
|
||||
@@ -1362,7 +1362,7 @@ help(struct tab *ctab, char *s)
|
||||
columns = 1;
|
||||
lines = (NCMDS + columns - 1) / columns;
|
||||
for (i = 0; i < lines; i++) {
|
||||
strcpy_truncate (buf, " ", sizeof(buf));
|
||||
strlcpy (buf, " ", sizeof(buf));
|
||||
for (j = 0; j < columns; j++) {
|
||||
c = ctab + j * lines + i;
|
||||
snprintf (buf + strlen(buf),
|
||||
@@ -1374,7 +1374,7 @@ help(struct tab *ctab, char *s)
|
||||
break;
|
||||
w = strlen(c->name) + 1;
|
||||
while (w < width) {
|
||||
strcat_truncate (buf,
|
||||
strlcat (buf,
|
||||
" ",
|
||||
sizeof(buf));
|
||||
w++;
|
||||
|
@@ -153,7 +153,7 @@ curdir(void)
|
||||
if (getcwd(path, sizeof(path)-1) == NULL)
|
||||
return ("");
|
||||
if (path[1] != '\0') /* special case for root dir. */
|
||||
strcat_truncate(path, "/", sizeof(path));
|
||||
strlcat(path, "/", sizeof(path));
|
||||
/* For guest account, skip / since it's chrooted */
|
||||
return (guest ? path+1 : path);
|
||||
}
|
||||
@@ -526,7 +526,7 @@ user(char *name)
|
||||
if (inet_ntop (his_addr->sa_family,
|
||||
socket_get_address(his_addr),
|
||||
data_addr, sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr, "unknown address",
|
||||
strlcpy (data_addr, "unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
syslog(LOG_NOTICE,
|
||||
@@ -556,7 +556,7 @@ user(char *name)
|
||||
socket_get_address(his_addr),
|
||||
data_addr,
|
||||
sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr,
|
||||
strlcpy (data_addr,
|
||||
"unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
@@ -571,7 +571,7 @@ user(char *name)
|
||||
}
|
||||
}
|
||||
if (logging)
|
||||
strcpy_truncate(curname, name, sizeof(curname));
|
||||
strlcpy(curname, name, sizeof(curname));
|
||||
if(sec_complete) {
|
||||
if(sec_userok(name) == 0)
|
||||
do_login(232, name);
|
||||
@@ -786,7 +786,7 @@ int do_login(int code, char *passwd)
|
||||
if (inet_ntop (his_addr->sa_family,
|
||||
socket_get_address(his_addr),
|
||||
data_addr, sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr, "unknown address",
|
||||
strlcpy (data_addr, "unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
syslog(LOG_INFO, "ANONYMOUS FTP LOGIN FROM %s(%s), %s",
|
||||
@@ -807,7 +807,7 @@ int do_login(int code, char *passwd)
|
||||
if (inet_ntop (his_addr->sa_family,
|
||||
socket_get_address(his_addr),
|
||||
data_addr, sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr, "unknown address",
|
||||
strlcpy (data_addr, "unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
syslog(LOG_INFO, "FTP LOGIN FROM %s(%s) as %s",
|
||||
@@ -898,7 +898,7 @@ pass(char *passwd)
|
||||
if (inet_ntop (his_addr->sa_family,
|
||||
socket_get_address(his_addr),
|
||||
data_addr, sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr, "unknown address",
|
||||
strlcpy (data_addr, "unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
reply(530, "Login incorrect.");
|
||||
@@ -1242,7 +1242,7 @@ dataconn(char *name, off_t size, char *mode)
|
||||
if (inet_ntop (data_source->sa_family,
|
||||
socket_get_address(data_source),
|
||||
data_addr, sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr, "unknown address",
|
||||
strlcpy (data_addr, "unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
reply(425, "Can't create data socket (%s,%d): %s.",
|
||||
@@ -1781,7 +1781,7 @@ dolog(struct sockaddr *sa)
|
||||
if (inet_ntop (his_addr->sa_family,
|
||||
socket_get_address(his_addr),
|
||||
data_addr, sizeof(data_addr)) == NULL)
|
||||
strcpy_truncate (data_addr, "unknown address",
|
||||
strlcpy (data_addr, "unknown address",
|
||||
sizeof(data_addr));
|
||||
|
||||
|
||||
|
@@ -85,7 +85,7 @@ store_ticket(KTEXT cip)
|
||||
return(INTK_BADPW);
|
||||
|
||||
/* extract server's name */
|
||||
strcpy_truncate(sp.name, ptr, sizeof(sp.name));
|
||||
strlcpy(sp.name, ptr, sizeof(sp.name));
|
||||
ptr += len + 1;
|
||||
left -= len + 1;
|
||||
|
||||
@@ -94,7 +94,7 @@ store_ticket(KTEXT cip)
|
||||
return(INTK_BADPW);
|
||||
|
||||
/* extract server's instance */
|
||||
strcpy_truncate(sp.instance, ptr, sizeof(sp.instance));
|
||||
strlcpy(sp.instance, ptr, sizeof(sp.instance));
|
||||
ptr += len + 1;
|
||||
left -= len + 1;
|
||||
|
||||
@@ -103,7 +103,7 @@ store_ticket(KTEXT cip)
|
||||
return(INTK_BADPW);
|
||||
|
||||
/* extract server's realm */
|
||||
strcpy_truncate(sp.realm, ptr, sizeof(sp.realm));
|
||||
strlcpy(sp.realm, ptr, sizeof(sp.realm));
|
||||
ptr += len + 1;
|
||||
left -= len + 1;
|
||||
|
||||
@@ -304,12 +304,12 @@ klist(void)
|
||||
" Issued", " Expires", " Principal (kvno)");
|
||||
header = 0;
|
||||
}
|
||||
strcpy_truncate(buf1, short_date(c.issue_date), sizeof(buf1));
|
||||
strlcpy(buf1, short_date(c.issue_date), sizeof(buf1));
|
||||
c.issue_date = krb_life_to_time(c.issue_date, c.lifetime);
|
||||
if (time(0) < (unsigned long) c.issue_date)
|
||||
strcpy_truncate(buf2, short_date(c.issue_date), sizeof(buf2));
|
||||
strlcpy(buf2, short_date(c.issue_date), sizeof(buf2));
|
||||
else
|
||||
strcpy_truncate(buf2, ">>> Expired <<< ", sizeof(buf2));
|
||||
strlcpy(buf2, ">>> Expired <<< ", sizeof(buf2));
|
||||
lreply(200, "%s %s %s (%d)", buf1, buf2,
|
||||
krb_unparse_name_long(c.service, c.instance, c.realm), c.kvno);
|
||||
}
|
||||
|
@@ -89,10 +89,10 @@ ftp_rooted(const char *path)
|
||||
|
||||
if(!home[0])
|
||||
if((pwd = k_getpwnam("ftp")))
|
||||
strcpy_truncate(home, pwd->pw_dir, sizeof(home));
|
||||
strlcpy(home, pwd->pw_dir, sizeof(home));
|
||||
snprintf(newpath, sizeof(newpath), "%s/%s", home, path);
|
||||
if(access(newpath, X_OK))
|
||||
strcpy_truncate(newpath, path, sizeof(newpath));
|
||||
strlcpy(newpath, path, sizeof(newpath));
|
||||
return newpath;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user