/* copy the first 8 chars of the password for unix crypt */
strncpy(user_pwcopy, pass, sizeof(user_pwcopy));
- user_pwcopy[8]='\0';
+ user_pwcopy[sizeof(user_pwcopy) - 1]='\0';
namep = crypt(user_pwcopy, salt);
memset (user_pwcopy, 0, sizeof(user_pwcopy));
/* ... and wipe the copy now that we have the string */
unlink(ccfile+strlen("FILE:"));
} else {
/* note it correctly */
- strcpy(ccfile, getenv(KRB5_ENV_CCNAME));
+ strncpy(ccfile, getenv(KRB5_ENV_CCNAME), sizeof(ccfile));
+ ccfile[sizeof(ccfile) - 1] = '\0';
}
#ifdef KRB4_GET_TICKETS
if (krb_get_lrealm(realm, 1) != KSUCCESS) {
strncpy(realm, KRB_REALM, sizeof(realm));
+ realm[sizeof(realm) - 1] = '\0';
}
if (login_krb4_get_tickets || login_krb4_convert) {
/* Set up the ticket file environment variable */
strncpy(tkfile, KRB_TK_DIR, sizeof(tkfile));
+ tkfile[sizeof(tkfile) - 1] = '\0';
strncat(tkfile, strrchr(ttyn, '/')+1,
sizeof(tkfile) - strlen(tkfile));
(void) unlink (tkfile);
} else {
/* get_name pulls out just the name not the
type */
- strcpy(ccfile, krb5_cc_get_name(kcontext, ccache));
+ strncpy(ccfile, krb5_cc_get_name(kcontext, ccache), sizeof(ccfile));
+ ccfile[sizeof(ccfile) - 1] = '\0';
krbflag = got_v5_tickets = 1;
return 1;
}
return 0;
}
got_v4_tickets = 1;
- strcpy(tkfile, tkt_string());
+ strncpy(tkfile, tkt_string(), sizeof(tkfile));
+ tkfile[sizeof(tkfile) - 1] = '\0';
return 1;
}
#endif
case INTK_OK:
kpass_ok = 1;
krbflag = 1;
- strcpy(tkfile, tkt_string());
+ strncpy(tkfile, tkt_string(), sizeof(tkfile));
+ tkfile[sizeof(tkfile) - 1] = '\0';
break;
/* These errors should be silent */
/* So the Kerberos database can't be probed */
/* since krb5_sname_to_principal has done the work for us, just
extract the name directly */
- strncpy(phost, krb5_princ_component(c, princ, 1)->data, BUFSIZ);
+ strncpy(phost, krb5_princ_component(c, princ, 1)->data, sizeof(phost));
+ phost[sizeof(phost) - 1] = '\0';
/* Do we have host/<host> keys? */
/* (use default keytab, kvno IGNORE_VNO to get the first match,
lgetstr(term, sizeof(term), "Terminal type");
else if (!(kflag || Kflag )) /*Preserve terminal if not read over net */
{
- if (getenv("TERM"))
+ if (getenv("TERM")) {
strncpy(term, getenv("TERM"), sizeof(term));
+ term[sizeof(term) - 1] = '\0';
+ }
}
term_init (rflag || kflag || Kflag || eflag);
setenv("USER", pwd->pw_name, 1);
setenv("SHELL", pwd->pw_shell, 1);
- if (term[0] == '\0')
+ if (term[0] == '\0') {
(void) strncpy(term, stypeof(tty), sizeof(term));
+ term[sizeof(term) - 1] = '\0';
+ }
if (term[0])
(void)setenv("TERM", term, 0);
#ifdef KRB4_GET_TICKETS
handler_set (SIGTSTP, sa);
tbuf[0] = '-';
- (void) strcpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ?
- p + 1 : pwd->pw_shell);
+ (void) strncpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ?
+ p + 1 : pwd->pw_shell, sizeof(tbuf) - 1);
+ tbuf[sizeof(tbuf) - 1] = '\0';
execlp(pwd->pw_shell, tbuf, 0);
fprintf(stderr, "login: no shell: ");
perror(pwd->pw_shell);
}
(void)time(&ll.ll_time);
(void) strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
- if (hostname)
+ ll.ll_line[sizeof(ll.ll_line) - 1] = '\0';
+ if (hostname) {
(void) strncpy(ll.ll_host, hostname, sizeof(ll.ll_host));
- else
+ ll.ll_host[sizeof(ll.ll_host) - 1] = '\0';
+ } else
(void) memset(ll.ll_host, 0, sizeof(ll.ll_host));
(void)write(fd, (char *)&ll, sizeof(ll));
(void)close(fd);