From bf75fac82ab1ca3572a4ce8a6918ff321ae29b1d Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Thu, 16 Sep 1999 20:41:57 +0000 Subject: [PATCH] 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 --- appl/ftp/ftp/cmds.c | 36 +++++++++++++++--------------- appl/ftp/ftp/domacro.c | 2 +- appl/ftp/ftp/ftp.c | 28 +++++++++++------------ appl/ftp/ftp/krb4.c | 18 +++++++-------- appl/ftp/ftp/main.c | 4 ++-- appl/ftp/ftp/ruserpass.c | 6 ++--- appl/ftp/ftpd/ftpcmd.y | 6 ++--- appl/ftp/ftpd/ftpd.c | 18 +++++++-------- appl/ftp/ftpd/kauth.c | 12 +++++----- appl/ftp/ftpd/popen.c | 4 ++-- appl/kx/common.c | 2 +- appl/otp/otp.c | 4 ++-- appl/popper/pop_debug.c | 2 +- appl/popper/pop_dropcopy.c | 2 +- appl/popper/pop_dropinfo.c | 2 +- appl/popper/pop_get_command.c | 2 +- appl/popper/pop_init.c | 8 +++---- appl/popper/pop_msg.c | 2 +- appl/popper/pop_user.c | 2 +- appl/telnet/ChangeLog | 5 +++++ appl/telnet/libtelnet/kerberos.c | 14 ++++++------ appl/telnet/libtelnet/kerberos5.c | 16 ++++++------- appl/telnet/libtelnet/krb4encpwd.c | 14 ++++++------ appl/telnet/libtelnet/rsaencpwd.c | 12 +++++----- appl/telnet/libtelnet/spx.c | 8 +++---- appl/telnet/telnet/authenc.c | 2 +- appl/telnet/telnet/commands.c | 14 ++++++------ appl/telnet/telnet/main.c | 2 +- appl/telnet/telnet/utilities.c | 4 ++-- appl/telnet/telnetd/sys_term.c | 4 ++-- appl/telnet/telnetd/telnetd.c | 10 ++++----- appl/telnet/telnetd/utility.c | 2 +- appl/xnlock/xnlock.c | 14 ++++++------ lib/auth/pam/pam.c | 6 ++--- lib/com_err/Makefile.in | 8 +++---- lib/des/passwd_dlg.c | 2 +- lib/kafs/Makefile.in | 12 +++++----- lib/kafs/afssys.c | 2 +- lib/kafs/common.c | 2 +- lib/kafs/dlfcn.c | 28 +++++++++++------------ lib/otp/otp_db.c | 2 +- lib/otp/otp_print.c | 4 ++-- 42 files changed, 176 insertions(+), 171 deletions(-) diff --git a/appl/ftp/ftp/cmds.c b/appl/ftp/ftp/cmds.c index 0dbf7673c..8040b07b8 100644 --- a/appl/ftp/ftp/cmds.c +++ b/appl/ftp/ftp/cmds.c @@ -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) { diff --git a/appl/ftp/ftp/domacro.c b/appl/ftp/ftp/domacro.c index 47af7f696..51651208e 100644 --- a/appl/ftp/ftp/domacro.c +++ b/appl/ftp/ftp/domacro.c @@ -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) { diff --git a/appl/ftp/ftp/ftp.c b/appl/ftp/ftp/ftp.c index 770c50590..5a8038d9d 100644 --- a/appl/ftp/ftp/ftp.c +++ b/appl/ftp/ftp/ftp.c @@ -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) { diff --git a/appl/ftp/ftp/krb4.c b/appl/ftp/ftp/krb4.c index b4dd31cb4..d3d295b2d 100644 --- a/appl/ftp/ftp/krb4.c +++ b/appl/ftp/ftp/krb4.c @@ -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); diff --git a/appl/ftp/ftp/main.c b/appl/ftp/ftp/main.c index b8d601d40..6c5707079 100644 --- a/appl/ftp/ftp/main.c +++ b/appl/ftp/ftp/main.c @@ -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{ diff --git a/appl/ftp/ftp/ruserpass.c b/appl/ftp/ftp/ruserpass.c index 6d47e0cc5..00cfd0cf5 100644 --- a/appl/ftp/ftp/ruserpass.c +++ b/appl/ftp/ftp/ruserpass.c @@ -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; } } diff --git a/appl/ftp/ftpd/ftpcmd.y b/appl/ftp/ftpd/ftpcmd.y index 3d3dab4ab..d521b2d4b 100644 --- a/appl/ftp/ftpd/ftpcmd.y +++ b/appl/ftp/ftpd/ftpcmd.y @@ -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++; diff --git a/appl/ftp/ftpd/ftpd.c b/appl/ftp/ftpd/ftpd.c index 53a3cabf6..c1ed3c215 100644 --- a/appl/ftp/ftpd/ftpd.c +++ b/appl/ftp/ftpd/ftpd.c @@ -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)); diff --git a/appl/ftp/ftpd/kauth.c b/appl/ftp/ftpd/kauth.c index 1f2084c67..405b48138 100644 --- a/appl/ftp/ftpd/kauth.c +++ b/appl/ftp/ftpd/kauth.c @@ -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); } diff --git a/appl/ftp/ftpd/popen.c b/appl/ftp/ftpd/popen.c index ce4df55ad..316ef956b 100644 --- a/appl/ftp/ftpd/popen.c +++ b/appl/ftp/ftpd/popen.c @@ -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; } diff --git a/appl/kx/common.c b/appl/kx/common.c index 4ab51c7d2..369cd574f 100644 --- a/appl/kx/common.c +++ b/appl/kx/common.c @@ -416,7 +416,7 @@ create_and_write_cookie (char *xauthfile, auth.data = (char*)cookie; des_rand_data (cookie, cookie_sz); - strcpy_truncate(xauthfile, "/tmp/AXXXXXX", xauthfile_size); + strlcpy(xauthfile, "/tmp/AXXXXXX", xauthfile_size); fd = mkstemp(xauthfile); if(fd < 0) { saved_errno = errno; diff --git a/appl/otp/otp.c b/appl/otp/otp.c index 8d8f4928b..d09858059 100644 --- a/appl/otp/otp.c +++ b/appl/otp/otp.c @@ -89,7 +89,7 @@ renew (int argc, char **argv, OtpAlgorithm *alg, char *user) newctx.alg = alg; newctx.user = user; newctx.n = atoi (argv[0]); - strcpy_truncate (newctx.seed, argv[1], sizeof(newctx.seed)); + strlcpy (newctx.seed, argv[1], sizeof(newctx.seed)); strlwr(newctx.seed); snprintf (prompt, sizeof(prompt), "[ otp-%s %u %s ]", @@ -155,7 +155,7 @@ set (int argc, char **argv, OtpAlgorithm *alg, char *user) err (1, "out of memory"); ctx.n = atoi (argv[0]); - strcpy_truncate (ctx.seed, argv[1], sizeof(ctx.seed)); + strlcpy (ctx.seed, argv[1], sizeof(ctx.seed)); strlwr(ctx.seed); do { if (des_read_pw_string (pw, sizeof(pw), "Pass-phrase: ", 1)) diff --git a/appl/popper/pop_debug.c b/appl/popper/pop_debug.c index 4bf27bffa..54898d6fb 100644 --- a/appl/popper/pop_debug.c +++ b/appl/popper/pop_debug.c @@ -56,7 +56,7 @@ loop(int s) if(FD_ISSET(0, &fds)){ fgets(cmd, sizeof(cmd), stdin); cmd[strlen(cmd) - 1] = '\0'; - strcat_truncate (cmd, "\r\n", sizeof(cmd)); + strlcat (cmd, "\r\n", sizeof(cmd)); write(s, cmd, strlen(cmd)); } if(FD_ISSET(s, &fds)){ diff --git a/appl/popper/pop_dropcopy.c b/appl/popper/pop_dropcopy.c index 7abbbc8ca..a6ff44405 100644 --- a/appl/popper/pop_dropcopy.c +++ b/appl/popper/pop_dropcopy.c @@ -73,7 +73,7 @@ pop_dropcopy(POP *p, struct passwd *pwp) * running as root. */ - strcpy_truncate(template, POP_TMPDROP, sizeof(template)); + strlcpy(template, POP_TMPDROP, sizeof(template)); if ((tf_fd = mkstemp(template)) < 0 || (tf = fdopen(tf_fd, "w+")) == NULL) { pop_log(p,POP_PRIORITY, diff --git a/appl/popper/pop_dropinfo.c b/appl/popper/pop_dropinfo.c index 58ada5863..404560747 100644 --- a/appl/popper/pop_dropinfo.c +++ b/appl/popper/pop_dropinfo.c @@ -196,7 +196,7 @@ pop_dropinfo(POP *p) "Msg %d at offset %ld being added to list", mp->number, mp->offset); #endif /* DEBUG */ - }else if(in_header) + } else if(in_header) parse_header(mp, buffer); blank_line = (strncmp(buffer, "\n", nchar) == 0); if(blank_line) { diff --git a/appl/popper/pop_get_command.c b/appl/popper/pop_get_command.c index b7a857aa4..c1f628dca 100644 --- a/appl/popper/pop_get_command.c +++ b/appl/popper/pop_get_command.c @@ -49,7 +49,7 @@ pop_get_command(POP *p, char *mp) /* Save a copy of the original client line */ #ifdef DEBUG - if(p->debug) strcpy_truncate (buf, mp, sizeof(buf)); + if(p->debug) strlcpy (buf, mp, sizeof(buf)); #endif /* DEBUG */ /* Parse the message into the parameter array */ diff --git a/appl/popper/pop_init.c b/appl/popper/pop_init.c index 3ae245604..009178c91 100644 --- a/appl/popper/pop_init.c +++ b/appl/popper/pop_init.c @@ -319,7 +319,7 @@ pop_init(POP *p,int argcount,char **argmessage) if (ch == NULL){ pop_log(p,POP_PRIORITY, "Unable to get canonical name of client, err = %d",error); - strcpy_truncate (p->client, p->ipaddr, sizeof(p->client)); + strlcpy (p->client, p->ipaddr, sizeof(p->client)); } /* Save the cannonical name of the client host in the POP parameter block */ @@ -339,12 +339,12 @@ pop_init(POP *p,int argcount,char **argmessage) pop_log(p,POP_PRIORITY, "Client at \"%s\" resolves to an unknown host name \"%s\"", p->ipaddr,ch->h_name); - strcpy_truncate (p->client, p->ipaddr, sizeof(p->client)); + strlcpy (p->client, p->ipaddr, sizeof(p->client)); } else { /* Save the host name (the previous value was destroyed by gethostbyname) */ - strcpy_truncate (p->client, ch->h_name, sizeof(p->client)); + strlcpy (p->client, ch->h_name, sizeof(p->client)); /* Look for the client's IP address in the list returned for its name */ @@ -358,7 +358,7 @@ pop_init(POP *p,int argcount,char **argmessage) pop_log (p,POP_PRIORITY, "Client address \"%s\" not listed for its host name \"%s\"", p->ipaddr,ch->h_name); - strcpy_truncate (p->client, p->ipaddr, sizeof(p->client)); + strlcpy (p->client, p->ipaddr, sizeof(p->client)); } } freehostent (ch_again); diff --git a/appl/popper/pop_msg.c b/appl/popper/pop_msg.c index b8bd2a5e6..9e3647b4c 100644 --- a/appl/popper/pop_msg.c +++ b/appl/popper/pop_msg.c @@ -46,7 +46,7 @@ pop_msg(POP *p, int stat, char *format, ...) pop_log(p,POP_PRIORITY,"%s",message); /* Append the */ - strcat_truncate(message, "\r\n", sizeof(message)); + strlcat(message, "\r\n", sizeof(message)); /* Send the message to the client */ fputs(message, p->output); diff --git a/appl/popper/pop_user.c b/appl/popper/pop_user.c index c8cf08a69..fc286b4d7 100644 --- a/appl/popper/pop_user.c +++ b/appl/popper/pop_user.c @@ -16,7 +16,7 @@ pop_user (POP *p) { char ss[256]; - strcpy_truncate(p->user, p->pop_parm[1], sizeof(p->user)); + strlcpy(p->user, p->pop_parm[1], sizeof(p->user)); #ifdef OTP if (otp_challenge (&p->otp_ctx, p->user, ss, sizeof(ss)) == 0) { diff --git a/appl/telnet/ChangeLog b/appl/telnet/ChangeLog index 34801e23a..3654c60ea 100644 --- a/appl/telnet/ChangeLog +++ b/appl/telnet/ChangeLog @@ -1,3 +1,8 @@ +1999-09-16 Assar Westerlund + + * telnet/commands.c: revert 1.54, get_default_username should DTRT + now + 1999-09-05 Assar Westerlund * telnetd/utility.c (ttloop): make it return 1 if interrupted by a diff --git a/appl/telnet/libtelnet/kerberos.c b/appl/telnet/libtelnet/kerberos.c index 36b1b38ce..8d3568615 100644 --- a/appl/telnet/libtelnet/kerberos.c +++ b/appl/telnet/libtelnet/kerberos.c @@ -180,7 +180,7 @@ kerberos4_send(char *name, Authenticator *ap) memset(instance, 0, sizeof(instance)); - strcpy_truncate (instance, + strlcpy (instance, krb_get_phost(RemoteHostName), INST_SZ); @@ -521,7 +521,7 @@ kerberos4_status(Authenticator *ap, char *name, size_t name_sz, int level) return(level); if (UserNameRequested && !kuserok(&adat, UserNameRequested)) { - strcpy_truncate(name, UserNameRequested, name_sz); + strlcpy(name, UserNameRequested, name_sz); return(AUTH_VALID); } else return(AUTH_USER); @@ -540,11 +540,11 @@ kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen) switch(data[3]) { case KRB_REJECT: /* Rejected (reason might follow) */ - strcpy_truncate((char *)buf, " REJECT ", buflen); + strlcpy((char *)buf, " REJECT ", buflen); goto common; case KRB_ACCEPT: /* Accepted (name might follow) */ - strcpy_truncate((char *)buf, " ACCEPT ", buflen); + strlcpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) @@ -557,15 +557,15 @@ kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen) break; case KRB_AUTH: /* Authentication data follows */ - strcpy_truncate((char *)buf, " AUTH", buflen); + strlcpy((char *)buf, " AUTH", buflen); goto common2; case KRB_CHALLENGE: - strcpy_truncate((char *)buf, " CHALLENGE", buflen); + strlcpy((char *)buf, " CHALLENGE", buflen); goto common2; case KRB_RESPONSE: - strcpy_truncate((char *)buf, " RESPONSE", buflen); + strlcpy((char *)buf, " RESPONSE", buflen); goto common2; default: diff --git a/appl/telnet/libtelnet/kerberos5.c b/appl/telnet/libtelnet/kerberos5.c index 82e741d34..9d267fd87 100644 --- a/appl/telnet/libtelnet/kerberos5.c +++ b/appl/telnet/libtelnet/kerberos5.c @@ -587,7 +587,7 @@ kerberos5_status(Authenticator *ap, char *name, size_t name_sz, int level) ticket->client, UserNameRequested)) { - strcpy_truncate(name, UserNameRequested, name_sz); + strlcpy(name, UserNameRequested, name_sz); return(AUTH_VALID); } else return(AUTH_USER); @@ -606,11 +606,11 @@ kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen) switch(data[3]) { case KRB_REJECT: /* Rejected (reason might follow) */ - strcpy_truncate((char *)buf, " REJECT ", buflen); + strlcpy((char *)buf, " REJECT ", buflen); goto common; case KRB_ACCEPT: /* Accepted (name might follow) */ - strcpy_truncate((char *)buf, " ACCEPT ", buflen); + strlcpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) @@ -624,24 +624,24 @@ kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen) case KRB_AUTH: /* Authentication data follows */ - strcpy_truncate((char *)buf, " AUTH", buflen); + strlcpy((char *)buf, " AUTH", buflen); goto common2; case KRB_RESPONSE: - strcpy_truncate((char *)buf, " RESPONSE", buflen); + strlcpy((char *)buf, " RESPONSE", buflen); goto common2; case KRB_FORWARD: /* Forwarded credentials follow */ - strcpy_truncate((char *)buf, " FORWARD", buflen); + strlcpy((char *)buf, " FORWARD", buflen); goto common2; case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */ - strcpy_truncate((char *)buf, " FORWARD_ACCEPT", buflen); + strlcpy((char *)buf, " FORWARD_ACCEPT", buflen); goto common2; case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */ /* (reason might follow) */ - strcpy_truncate((char *)buf, " FORWARD_REJECT", buflen); + strlcpy((char *)buf, " FORWARD_REJECT", buflen); goto common2; default: diff --git a/appl/telnet/libtelnet/krb4encpwd.c b/appl/telnet/libtelnet/krb4encpwd.c index 32c1ecac5..211d60ca1 100644 --- a/appl/telnet/libtelnet/krb4encpwd.c +++ b/appl/telnet/libtelnet/krb4encpwd.c @@ -308,7 +308,7 @@ krb4encpwd_reply(ap, data, cnt) des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0); UserPassword = user_passwd; Challenge = challenge; - strcpy_truncate(instance, RemoteHostName, sizeof(instance)); + strlcpy(instance, RemoteHostName, sizeof(instance)); if ((cp = strchr(instance, '.')) != 0) *cp = '\0'; if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) { @@ -338,7 +338,7 @@ krb4encpwd_status(ap, name, name_sz, level) return(level); if (UserNameRequested && passwdok(UserNameRequested, UserPassword)) { - strcpy_truncate(name, UserNameRequested, name_sz); + strlcpy(name, UserNameRequested, name_sz); return(AUTH_VALID); } else { return(AUTH_USER); @@ -360,11 +360,11 @@ krb4encpwd_printsub(data, cnt, buf, buflen) switch(data[3]) { case KRB4_ENCPWD_REJECT: /* Rejected (reason might follow) */ - strcpy_truncate((char *)buf, " REJECT ", buflen); + strlcpy((char *)buf, " REJECT ", buflen); goto common; case KRB4_ENCPWD_ACCEPT: /* Accepted (name might follow) */ - strcpy_truncate((char *)buf, " ACCEPT ", buflen); + strlcpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) @@ -377,15 +377,15 @@ krb4encpwd_printsub(data, cnt, buf, buflen) break; case KRB4_ENCPWD_AUTH: /* Authentication data follows */ - strcpy_truncate((char *)buf, " AUTH", buflen); + strlcpy((char *)buf, " AUTH", buflen); goto common2; case KRB4_ENCPWD_CHALLENGE: - strcpy_truncate((char *)buf, " CHALLENGE", buflen); + strlcpy((char *)buf, " CHALLENGE", buflen); goto common2; case KRB4_ENCPWD_ACK: - strcpy_truncate((char *)buf, " ACK", buflen); + strlcpy((char *)buf, " ACK", buflen); goto common2; default: diff --git a/appl/telnet/libtelnet/rsaencpwd.c b/appl/telnet/libtelnet/rsaencpwd.c index c53b9bfff..0d92d33c8 100644 --- a/appl/telnet/libtelnet/rsaencpwd.c +++ b/appl/telnet/libtelnet/rsaencpwd.c @@ -260,7 +260,7 @@ rsaencpwd_is(ap, data, cnt) snprintf(challenge, sizeof(challenge), "%x", now); challenge_len = strlen(challenge); } else { - strcpy_truncate(challenge, "randchal", sizeof(challenge)); + strlcpy(challenge, "randchal", sizeof(challenge)); challenge_len = 8; } @@ -392,7 +392,7 @@ rsaencpwd_status(ap, name, name_sz, level) return(level); if (UserNameRequested && rsaencpwd_passwdok(UserNameRequested, UserPassword)) { - strcpy_truncate(name, UserNameRequested, name_sz); + strlcpy(name, UserNameRequested, name_sz); return(AUTH_VALID); } else { return(AUTH_USER); @@ -414,11 +414,11 @@ rsaencpwd_printsub(data, cnt, buf, buflen) switch(data[3]) { case RSA_ENCPWD_REJECT: /* Rejected (reason might follow) */ - strcpy_truncate((char *)buf, " REJECT ", buflen); + strlcpy((char *)buf, " REJECT ", buflen); goto common; case RSA_ENCPWD_ACCEPT: /* Accepted (name might follow) */ - strcpy_truncate((char *)buf, " ACCEPT ", buflen); + strlcpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) @@ -431,11 +431,11 @@ rsaencpwd_printsub(data, cnt, buf, buflen) break; case RSA_ENCPWD_AUTH: /* Authentication data follows */ - strcpy_truncate((char *)buf, " AUTH", buflen); + strlcpy((char *)buf, " AUTH", buflen); goto common2; case RSA_ENCPWD_CHALLENGEKEY: - strcpy_truncate((char *)buf, " CHALLENGEKEY", buflen); + strlcpy((char *)buf, " CHALLENGEKEY", buflen); goto common2; default: diff --git a/appl/telnet/libtelnet/spx.c b/appl/telnet/libtelnet/spx.c index 0e0dd08c4..195d8f245 100644 --- a/appl/telnet/libtelnet/spx.c +++ b/appl/telnet/libtelnet/spx.c @@ -514,7 +514,7 @@ spx_status(ap, name, name_sz, level) &acl_file_buffer); if (major_status == GSS_S_COMPLETE) { - strcpy_truncate(name, UserNameRequested, name_sz); + strlcpy(name, UserNameRequested, name_sz); return(AUTH_VALID); } else { return(AUTH_USER); @@ -537,11 +537,11 @@ spx_printsub(data, cnt, buf, buflen) switch(data[3]) { case SPX_REJECT: /* Rejected (reason might follow) */ - strcpy_truncate((char *)buf, " REJECT ", buflen); + strlcpy((char *)buf, " REJECT ", buflen); goto common; case SPX_ACCEPT: /* Accepted (name might follow) */ - strcpy_truncate((char *)buf, " ACCEPT ", buflen); + strlcpy((char *)buf, " ACCEPT ", buflen); common: BUMP(buf, buflen); if (cnt <= 4) @@ -554,7 +554,7 @@ spx_printsub(data, cnt, buf, buflen) break; case SPX_AUTH: /* Authentication data follows */ - strcpy_truncate((char *)buf, " AUTH", buflen); + strlcpy((char *)buf, " AUTH", buflen); goto common2; default: diff --git a/appl/telnet/telnet/authenc.c b/appl/telnet/telnet/authenc.c index c2df29ca8..4a856c491 100644 --- a/appl/telnet/telnet/authenc.c +++ b/appl/telnet/telnet/authenc.c @@ -82,7 +82,7 @@ telnet_gets(char *prompt, char *result, int length, int echo) printf("%s", prompt); res = fgets(result, length, stdin); } else if ((res = getpass(prompt))) { - strcpy_truncate(result, res, length); + strlcpy(result, res, length); res = result; } TerminalNewMode(om); diff --git a/appl/telnet/telnet/commands.c b/appl/telnet/telnet/commands.c index 4218b0137..da1db3c0e 100644 --- a/appl/telnet/telnet/commands.c +++ b/appl/telnet/telnet/commands.c @@ -67,7 +67,7 @@ makeargv() cp = line; if (*cp == '!') { /* Special case shell escape */ /* save for shell command */ - strcpy_truncate(saveline, line, sizeof(saveline)); + strlcpy(saveline, line, sizeof(saveline)); *argp++ = "!"; /* No room in string to get this */ margc++; cp++; @@ -1583,7 +1583,7 @@ env_init(void) if (strchr(hbuf, '.') == 0) { struct hostent *he = roken_gethostbyname(hbuf); if (he != NULL) - strcpy_truncate(hbuf, he->h_name, 256); + strlcpy(hbuf, he->h_name, 256); } asprintf (&cp, "%s%s", hbuf, cp2); @@ -1981,7 +1981,7 @@ cmdrc(char *m1, char *m2) if (skiprc) return; - strcpy_truncate(m1save, m1, sizeof(m1save)); + strlcpy(m1save, m1, sizeof(m1save)); m1 = m1save; if (rcname[0] == 0) { @@ -2075,7 +2075,7 @@ tn(int argc, char **argv) return 0; } if (argc < 2) { - strcpy_truncate(line, "open ", sizeof(line)); + strlcpy(line, "open ", sizeof(line)); printf("(to) "); fgets(&line[strlen(line)], sizeof(line) - strlen(line), stdin); makeargv(); @@ -2146,7 +2146,7 @@ tn(int argc, char **argv) sin6.sin6_family = family = AF_INET6; sa = (struct sockaddr *)&sin6; sa_size = sizeof(sin6); - strcpy_truncate(_hostname, hostp, sizeof(_hostname)); + strlcpy(_hostname, hostp, sizeof(_hostname)); hostname =_hostname; } else #endif @@ -2154,7 +2154,7 @@ tn(int argc, char **argv) sin.sin_family = family = AF_INET; sa = (struct sockaddr *)&sin; sa_size = sizeof(sin); - strcpy_truncate(_hostname, hostp, sizeof(_hostname)); + strlcpy(_hostname, hostp, sizeof(_hostname)); hostname = _hostname; } else { #ifdef HAVE_GETHOSTBYNAME2 @@ -2167,7 +2167,7 @@ tn(int argc, char **argv) host = roken_gethostbyname(hostp); #endif if (host) { - strcpy_truncate(_hostname, host->h_name, sizeof(_hostname)); + strlcpy(_hostname, host->h_name, sizeof(_hostname)); family = host->h_addrtype; addr_list = host->h_addr_list; diff --git a/appl/telnet/telnet/main.c b/appl/telnet/telnet/main.c index f52de1b40..1790006e4 100644 --- a/appl/telnet/telnet/main.c +++ b/appl/telnet/telnet/main.c @@ -263,7 +263,7 @@ main(int argc, char **argv) extern char *dest_realm, dst_realm_buf[]; extern int dst_realm_sz; dest_realm = dst_realm_buf; - strcpy_truncate(dest_realm, optarg, dst_realm_sz); + strlcpy(dest_realm, optarg, dst_realm_sz); } #else fprintf(stderr, diff --git a/appl/telnet/telnet/utilities.c b/appl/telnet/telnet/utilities.c index c4fe08ad7..60f418716 100644 --- a/appl/telnet/telnet/utilities.c +++ b/appl/telnet/telnet/utilities.c @@ -82,13 +82,13 @@ SetNetTrace(char *file) if (file && (strcmp(file, "-") != 0)) { NetTrace = fopen(file, "w"); if (NetTrace) { - strcpy_truncate(NetTraceFile, file, sizeof(NetTraceFile)); + strlcpy(NetTraceFile, file, sizeof(NetTraceFile)); return; } fprintf(stderr, "Cannot open %s.\n", file); } NetTrace = stdout; - strcpy_truncate(NetTraceFile, "(standard output)", sizeof(NetTraceFile)); + strlcpy(NetTraceFile, "(standard output)", sizeof(NetTraceFile)); } void diff --git a/appl/telnet/telnetd/sys_term.c b/appl/telnet/telnetd/sys_term.c index 0e48ca1f3..9356cc049 100644 --- a/appl/telnet/telnetd/sys_term.c +++ b/appl/telnet/telnetd/sys_term.c @@ -388,7 +388,7 @@ int getpty(int *ptynum) p = _getpty(&master, O_RDWR, 0600, 1); if(p == NULL) return -1; - strcpy_truncate(line, p, sizeof(Xline)); + strlcpy(line, p, sizeof(Xline)); return master; #else @@ -420,7 +420,7 @@ int getpty(int *ptynum) #ifdef HAVE_UNLOCKPT unlockpt(p); #endif - strcpy_truncate(line, ptsname(p), sizeof(Xline)); + strlcpy(line, ptsname(p), sizeof(Xline)); really_stream = 1; return p; } diff --git a/appl/telnet/telnetd/telnetd.c b/appl/telnet/telnetd/telnetd.c index c5bb24821..e1bff9b67 100644 --- a/appl/telnet/telnetd/telnetd.c +++ b/appl/telnet/telnetd/telnetd.c @@ -594,12 +594,12 @@ getterminaltype(char *name, size_t name_sz) * we have to just go with what we (might) have already gotten. */ if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) { - strcpy_truncate(first, terminaltype, sizeof(first)); + strlcpy(first, terminaltype, sizeof(first)); for(;;) { /* * Save the unknown name, and request the next name. */ - strcpy_truncate(last, terminaltype, sizeof(last)); + strlcpy(last, terminaltype, sizeof(last)); _gettermname(); if (terminaltypeok(terminaltype)) break; @@ -731,7 +731,7 @@ Please contact your net administrator"); tmp = inet_ntop(af, addr, host_addr, sizeof(host_addr)); if (tmp == NULL) - strcpy_truncate (host_addr, "unknown address", sizeof(host_addr)); + strlcpy (host_addr, "unknown address", sizeof(host_addr)); if (host == NULL) host = host_addr; @@ -740,7 +740,7 @@ Please contact your net administrator"); * We must make a copy because Kerberos is probably going * to also do a gethost* and overwrite the static data... */ - strcpy_truncate(remote_host_name, host, sizeof(remote_host_name)); + strlcpy(remote_host_name, host, sizeof(remote_host_name)); if (hp != NULL) freehostent (hp); host = remote_host_name; @@ -762,7 +762,7 @@ Please contact your net administrator"); * If hostname still doesn't fit utmp, use ipaddr. */ if (strlen(remote_host_name) > abs(utmp_len)) - strcpy_truncate(remote_host_name, + strlcpy(remote_host_name, host_addr, sizeof(remote_host_name)); diff --git a/appl/telnet/telnetd/utility.c b/appl/telnet/telnetd/utility.c index 3e74129fd..b064352c9 100644 --- a/appl/telnet/telnetd/utility.c +++ b/appl/telnet/telnetd/utility.c @@ -400,7 +400,7 @@ void edithost(char *pat, char *host) pat++; } if (*host) - strcpy_truncate (res, host, + strlcpy (res, host, sizeof editedhost - (res - editedhost)); else *res = '\0'; diff --git a/appl/xnlock/xnlock.c b/appl/xnlock/xnlock.c index 353dd193c..d9b47ed01 100644 --- a/appl/xnlock/xnlock.c +++ b/appl/xnlock/xnlock.c @@ -251,8 +251,8 @@ init_words (int argc, char **argv) errx (1, "cannot allocate memory for message"); appres.text[0] = 0; for(; i < j; i++){ - strcat_truncate(appres.text, argv[i], len); - strcat_truncate(appres.text, " ", len); + strlcat(appres.text, argv[i], len); + strlcat(appres.text, " ", len); } } } @@ -799,7 +799,7 @@ talk(int force_erase) XSetForeground(dpy, gc, White); talking = 1; walk(FRONT); - strcpy_truncate (buf, words, sizeof(buf)); + strlcpy (buf, words, sizeof(buf)); p = buf; /* possibly avoid a lot of work here @@ -834,7 +834,7 @@ talk(int force_erase) if ((w = XTextWidth(font, p, p2 - p)) > width) width = w; total += p2 - p; /* total chars; count to determine reading time */ - strcpy_truncate(args[height], p, sizeof(args[height])); + strlcpy(args[height], p, sizeof(args[height])); if (height == MAXLINES - 1) { puts("Message too long!"); break; @@ -929,14 +929,14 @@ main (int argc, char **argv) struct passwd *pw; if (!(pw = k_getpwuid(0))) errx (1, "can't get root's passwd!"); - strcpy_truncate(root_cpass, pw->pw_passwd, sizeof(root_cpass)); + strlcpy(root_cpass, pw->pw_passwd, sizeof(root_cpass)); if (!(pw = k_getpwuid(getuid()))) errx (1, "Can't get your password entry!"); - strcpy_truncate(user_cpass, pw->pw_passwd, sizeof(user_cpass)); + strlcpy(user_cpass, pw->pw_passwd, sizeof(user_cpass)); setuid(getuid()); /* Now we're no longer running setuid root. */ - strcpy_truncate(login, pw->pw_name, sizeof(login)); + strlcpy(login, pw->pw_name, sizeof(login)); } srand(getpid()); diff --git a/lib/auth/pam/pam.c b/lib/auth/pam/pam.c index 91dc76656..5bf8649ee 100644 --- a/lib/auth/pam/pam.c +++ b/lib/auth/pam/pam.c @@ -150,10 +150,10 @@ auth_su(pam_handle_t *pamh, int flags, char *user, struct pam_conv *conv) pw = getpwuid(getuid()); if(strcmp(user, "root") == 0){ - strcpy_truncate(pr.name, pw->pw_name, sizeof(pr.name)); - strcpy_truncate(pr.instance, "root", sizeof(pr.instance)); + strlcpy(pr.name, pw->pw_name, sizeof(pr.name)); + strlcpy(pr.instance, "root", sizeof(pr.instance)); }else{ - strcpy_truncate(pr.name, user, sizeof(pr.name)); + strlcpy(pr.name, user, sizeof(pr.name)); pr.instance[0] = 0; } pmsg = &msg; diff --git a/lib/com_err/Makefile.in b/lib/com_err/Makefile.in index 8a68a5022..b604cf891 100644 --- a/lib/com_err/Makefile.in +++ b/lib/com_err/Makefile.in @@ -141,10 +141,10 @@ lex.c: $(srcdir)/lex.l snprintf.c: $(LN_S) $(srcdir)/../roken/snprintf.c . -strcat_truncate.c: - $(LN_S) $(srcdir)/../roken/strcat_truncate.c . +strlcat.c: + $(LN_S) $(srcdir)/../roken/strlcat.c . -strcpy_truncate.c: - $(LN_S) $(srcdir)/../roken/strcpy_truncate.c . +strlcpy.c: + $(LN_S) $(srcdir)/../roken/strlcpy.c . .PHONY: all Wall install uninstall clean mostlyclean distclean realclean diff --git a/lib/des/passwd_dlg.c b/lib/des/passwd_dlg.c index 9c42936a7..7728e0300 100644 --- a/lib/des/passwd_dlg.c +++ b/lib/des/passwd_dlg.c @@ -84,7 +84,7 @@ pwd_dialog(char *buf, int size) switch(DialogBox(hInst,MAKEINTRESOURCE(IDD_PASSWD_DIALOG),wnd,pwd_dialog_proc)) { case IDOK: - strcpy_truncate(buf, passwd, size); + strlcpy(buf, passwd, size); memset (passwd, 0, sizeof(passwd)); return 0; case IDCANCEL: diff --git a/lib/kafs/Makefile.in b/lib/kafs/Makefile.in index 0b1989816..6197337ee 100644 --- a/lib/kafs/Makefile.in +++ b/lib/kafs/Makefile.in @@ -41,9 +41,9 @@ LIB = $(LIBNAME).$(LIBEXT) $(AFS_EXTRA_LIBS) SOURCES = afssys.c afskrb.c common.c afslib.c -EXTRA_SOURCE = issuid.c strcpy_truncate.c strcat_truncate.c +EXTRA_SOURCE = issuid.c strlcpy.c strlcat.c -EXTRA_OBJECT = issuid.o strcpy_truncate.o strcat_truncate.o +EXTRA_OBJECT = issuid.o strlcpy.o strlcat.o OBJECTS = afssys.o afskrb.o common.o $(EXTRA_OBJECT) $(AFS_EXTRA_OBJS) @@ -109,9 +109,9 @@ roken_rename.h: issuid.c: $(LN_S) $(srcdir)/../roken/issuid.c . -strcat_truncate.c: - $(LN_S) $(srcdir)/../roken/strcat_truncate.c . +strlcat.c: + $(LN_S) $(srcdir)/../roken/strlcat.c . -strcpy_truncate.c: - $(LN_S) $(srcdir)/../roken/strcpy_truncate.c . +strlcpy.c: + $(LN_S) $(srcdir)/../roken/strlcpy.c . diff --git a/lib/kafs/afssys.c b/lib/kafs/afssys.c index 62ef69e89..154292485 100644 --- a/lib/kafs/afssys.c +++ b/lib/kafs/afssys.c @@ -77,7 +77,7 @@ try_aix(void) * If we are root or running setuid don't trust AFSLIBPATH! */ if (getuid() != 0 && !issuid() && (p = getenv("AFSLIBPATH")) != NULL) - strcpy_truncate(path, p, sizeof(path)); + strlcpy(path, p, sizeof(path)); else snprintf(path, sizeof(path), "%s/afslib.so", LIBDIR); diff --git a/lib/kafs/common.c b/lib/kafs/common.c index 14b248297..38316d6b6 100644 --- a/lib/kafs/common.c +++ b/lib/kafs/common.c @@ -155,7 +155,7 @@ dns_find_cell(const char *cell, char *dbserver, size_t len) struct resource_record *rr = r->head; while(rr){ if(rr->type == T_AFSDB && rr->u.afsdb->preference == 1){ - strcpy_truncate(dbserver, + strlcpy(dbserver, rr->u.afsdb->domain, len); ok = 0; diff --git a/lib/kafs/dlfcn.c b/lib/kafs/dlfcn.c index 98e081ceb..e664fe3e5 100644 --- a/lib/kafs/dlfcn.c +++ b/lib/kafs/dlfcn.c @@ -142,7 +142,7 @@ void *dlopen(const char *path, int mode) if (errno == ENOEXEC) { char *tmp[BUFSIZ/sizeof(char *)]; if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1) - strcpy_truncate(errbuf, + strlcpy(errbuf, strerror(errno), sizeof(errbuf)); else { @@ -151,7 +151,7 @@ void *dlopen(const char *path, int mode) caterr(*p); } } else - strcat_truncate(errbuf, + strlcat(errbuf, strerror(errno), sizeof(errbuf)); return NULL; @@ -231,29 +231,29 @@ static void caterr(char *s) p++; switch(atoi(s)) { case L_ERROR_TOOMANY: - strcat_truncate(errbuf, "to many errors", sizeof(errbuf)); + strlcat(errbuf, "to many errors", sizeof(errbuf)); break; case L_ERROR_NOLIB: - strcat_truncate(errbuf, "can't load library", sizeof(errbuf)); - strcat_truncate(errbuf, p, sizeof(errbuf)); + strlcat(errbuf, "can't load library", sizeof(errbuf)); + strlcat(errbuf, p, sizeof(errbuf)); break; case L_ERROR_UNDEF: - strcat_truncate(errbuf, "can't find symbol", sizeof(errbuf)); - strcat_truncate(errbuf, p, sizeof(errbuf)); + strlcat(errbuf, "can't find symbol", sizeof(errbuf)); + strlcat(errbuf, p, sizeof(errbuf)); break; case L_ERROR_RLDBAD: - strcat_truncate(errbuf, "bad RLD", sizeof(errbuf)); - strcat_truncate(errbuf, p, sizeof(errbuf)); + strlcat(errbuf, "bad RLD", sizeof(errbuf)); + strlcat(errbuf, p, sizeof(errbuf)); break; case L_ERROR_FORMAT: - strcat_truncate(errbuf, "bad exec format in", sizeof(errbuf)); - strcat_truncate(errbuf, p, sizeof(errbuf)); + strlcat(errbuf, "bad exec format in", sizeof(errbuf)); + strlcat(errbuf, p, sizeof(errbuf)); break; case L_ERROR_ERRNO: - strcat_truncate(errbuf, strerror(atoi(++p)), sizeof(errbuf)); + strlcat(errbuf, strerror(atoi(++p)), sizeof(errbuf)); break; default: - strcat_truncate(errbuf, s, sizeof(errbuf)); + strlcat(errbuf, s, sizeof(errbuf)); break; } } @@ -519,7 +519,7 @@ static int readExports(ModulePtr mp) * must copy the first SYMNMLEN chars and make * sure we have a zero byte at the end. */ - strcpy_truncate (tmpsym, ls->l_name, + strlcpy (tmpsym, ls->l_name, SYMNMLEN + 1); symname = tmpsym; } diff --git a/lib/otp/otp_db.c b/lib/otp/otp_db.c index f51398d34..6f6d28d6e 100644 --- a/lib/otp/otp_db.c +++ b/lib/otp/otp_db.c @@ -145,7 +145,7 @@ otp_get_internal (void *v, OtpContext *ctx, int lockp) p += 4; memcpy (ctx->key, p, OTPKEYSIZE); p += OTPKEYSIZE; - strcpy_truncate (ctx->seed, p, sizeof(ctx->seed)); + strlcpy (ctx->seed, p, sizeof(ctx->seed)); if (lockp) return dbm_store (dbm, key, dat, DBM_REPLACE); else diff --git a/lib/otp/otp_print.c b/lib/otp/otp_print.c index 482e15be9..7e84c9314 100644 --- a/lib/otp/otp_print.c +++ b/lib/otp/otp_print.c @@ -88,7 +88,7 @@ otp_print_hex (OtpKey key, char *str, size_t sz) void otp_print_hex_extended (OtpKey key, char *str, size_t sz) { - strcpy_truncate (str, OTP_HEXPREFIX, sz); + strlcpy (str, OTP_HEXPREFIX, sz); otp_print_hex (key, str + strlen(OTP_HEXPREFIX), sz - strlen(OTP_HEXPREFIX)); @@ -97,7 +97,7 @@ otp_print_hex_extended (OtpKey key, char *str, size_t sz) void otp_print_stddict_extended (OtpKey key, char *str, size_t sz) { - strcpy_truncate (str, OTP_WORDPREFIX, sz); + strlcpy (str, OTP_WORDPREFIX, sz); otp_print_stddict (key, str + strlen(OTP_WORDPREFIX), sz - strlen(OTP_WORDPREFIX));