strc{py,at}_truncate -> strlc{py,at}
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6985 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
1999-09-16 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* configure.in: test for strlcpy, strlcat
|
||||
|
||||
1999-09-14 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* lib/krb5/init_creds_pw.c (krb5_get_init_creds_password): return
|
||||
|
@@ -279,7 +279,7 @@ proto (int sock, const char *service)
|
||||
goto out;
|
||||
|
||||
}
|
||||
strcpy_truncate(krb5_tkfile,ccname,sizeof(krb5_tkfile));
|
||||
strlcpy(krb5_tkfile,ccname,sizeof(krb5_tkfile));
|
||||
syslog_and_cont("%s forwarded ticket to %s,%s",
|
||||
name,
|
||||
(char *)(remotename.data),ccname);
|
||||
|
@@ -467,7 +467,7 @@ do_login(struct passwd *pwd, char *tty, char *ttyn)
|
||||
/* all kinds of different magic */
|
||||
|
||||
#ifdef HAVE_SHADOW_H
|
||||
check_shadow(pwd,sp);
|
||||
check_shadow(pwd, sp);
|
||||
#endif
|
||||
|
||||
if(do_osfc2_magic(pwd->pw_uid))
|
||||
@@ -637,7 +637,7 @@ main(int argc, char **argv)
|
||||
|
||||
if(*argv){
|
||||
if(strchr(*argv, '=') == NULL && strcmp(*argv, "-") != 0){
|
||||
strcpy_truncate (username, *argv, sizeof(username));
|
||||
strlcpy (username, *argv, sizeof(username));
|
||||
ask = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -368,7 +368,7 @@ recv_krb5_auth (int s, u_char *buf,
|
||||
if (inet_ntop (thataddr->sa_family,
|
||||
socket_get_address (thataddr),
|
||||
addr_str, sizeof(addr_str)) == NULL)
|
||||
strcpy_truncate (addr_str, "unknown address",
|
||||
strlcpy (addr_str, "unknown address",
|
||||
sizeof(addr_str));
|
||||
|
||||
syslog(LOG_INFO|LOG_AUTH,
|
||||
|
@@ -116,7 +116,7 @@ add_one_principal (const char *name,
|
||||
if(rand_key) {
|
||||
princ.attributes |= KRB5_KDB_DISALLOW_ALL_TIX;
|
||||
mask |= KADM5_ATTRIBUTES;
|
||||
strcpy_truncate (pwbuf, "hemlig", sizeof(pwbuf));
|
||||
strlcpy (pwbuf, "hemlig", sizeof(pwbuf));
|
||||
password = pwbuf;
|
||||
} else if (rand_password) {
|
||||
random_password (pwbuf, sizeof(pwbuf));
|
||||
|
@@ -74,7 +74,7 @@ random_password(char *pw, size_t len)
|
||||
"abcdefghijklmnopqrstuvwxyz", 7,
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ", 2,
|
||||
"@$%&*()-+=:,/<>1234567890", 1);
|
||||
strcpy_truncate(pw, pass, len);
|
||||
strlcpy(pw, pass, len);
|
||||
memset(pass, 0, strlen(pass));
|
||||
free(pass);
|
||||
#endif
|
||||
|
@@ -85,12 +85,12 @@ ret_vals(krb5_storage *sp, Kadm_vals *vals)
|
||||
switch(field) {
|
||||
case KADM_NAME:
|
||||
krb5_ret_stringz(sp, &tmp_string);
|
||||
strcpy_truncate(vals->name, tmp_string, sizeof(vals->name));
|
||||
strlcpy(vals->name, tmp_string, sizeof(vals->name));
|
||||
free(tmp_string);
|
||||
break;
|
||||
case KADM_INST:
|
||||
krb5_ret_stringz(sp, &tmp_string);
|
||||
strcpy_truncate(vals->instance, tmp_string,
|
||||
strlcpy(vals->instance, tmp_string,
|
||||
sizeof(vals->instance));
|
||||
free(tmp_string);
|
||||
break;
|
||||
@@ -113,13 +113,13 @@ ret_vals(krb5_storage *sp, Kadm_vals *vals)
|
||||
break;
|
||||
case KADM_MODNAME:
|
||||
krb5_ret_stringz(sp, &tmp_string);
|
||||
strcpy_truncate(vals->mod_name, tmp_string,
|
||||
strlcpy(vals->mod_name, tmp_string,
|
||||
sizeof(vals->mod_name));
|
||||
free(tmp_string);
|
||||
break;
|
||||
case KADM_MODINST:
|
||||
krb5_ret_stringz(sp, &tmp_string);
|
||||
strcpy_truncate(vals->mod_instance, tmp_string,
|
||||
strlcpy(vals->mod_instance, tmp_string,
|
||||
sizeof(vals->mod_instance));
|
||||
free(tmp_string);
|
||||
break;
|
||||
|
@@ -262,7 +262,7 @@ main(int argc, char **argv)
|
||||
socket_get_address (sa),
|
||||
addr_name,
|
||||
sizeof(addr_name)) == NULL)
|
||||
strcpy_truncate (addr_name, "unknown address",
|
||||
strlcpy (addr_name, "unknown address",
|
||||
sizeof(addr_name));
|
||||
|
||||
krb5_log(context, fac, 0, "Connection from %s", addr_name);
|
||||
|
@@ -318,13 +318,13 @@ display_tokens(int do_verbose)
|
||||
cell = r;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
strcpy_truncate (buf1, printable_time(ct.BeginTimestamp),
|
||||
strlcpy (buf1, printable_time(ct.BeginTimestamp),
|
||||
sizeof(buf1));
|
||||
if (do_verbose || tv.tv_sec < ct.EndTimestamp)
|
||||
strcpy_truncate (buf2, printable_time(ct.EndTimestamp),
|
||||
strlcpy (buf2, printable_time(ct.EndTimestamp),
|
||||
sizeof(buf2));
|
||||
else
|
||||
strcpy_truncate (buf2, ">>> Expired <<<", sizeof(buf2));
|
||||
strlcpy (buf2, ">>> Expired <<<", sizeof(buf2));
|
||||
|
||||
printf("%s %s ", buf1, buf2);
|
||||
|
||||
|
@@ -124,12 +124,12 @@ hdb_entry2string(krb5_context context, hdb_entry *ent, char **str)
|
||||
ret = krb5_unparse_name(context, ent->principal, &p);
|
||||
if(ret)
|
||||
return ret;
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
free(p);
|
||||
/* --- kvno */
|
||||
asprintf(&p, "%d", ent->kvno);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
free(p);
|
||||
/* --- keys */
|
||||
for(i = 0; i < ent->keys.len; i++){
|
||||
@@ -141,75 +141,75 @@ hdb_entry2string(krb5_context context, hdb_entry *ent, char **str)
|
||||
else
|
||||
asprintf(&p, "::%d:",
|
||||
ent->keys.val[i].key.keytype);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
free(p);
|
||||
/* --- keydata */
|
||||
append_hex(buf, &ent->keys.val[i].key.keyvalue);
|
||||
strcat_truncate(buf, ":", sizeof(buf));
|
||||
strlcat(buf, ":", sizeof(buf));
|
||||
/* --- salt */
|
||||
if(ent->keys.val[i].salt){
|
||||
asprintf(&p, "%u/", ent->keys.val[i].salt->type);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
free(p);
|
||||
append_hex(buf, &ent->keys.val[i].salt->salt);
|
||||
}else
|
||||
strcat_truncate(buf, "-", sizeof(buf));
|
||||
strlcat(buf, "-", sizeof(buf));
|
||||
}
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
/* --- created by */
|
||||
event2string(context, &ent->created_by, &p);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
free(p);
|
||||
/* --- modified by */
|
||||
event2string(context, ent->modified_by, &p);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
free(p);
|
||||
|
||||
/* --- valid start */
|
||||
if(ent->valid_start)
|
||||
strcat_truncate(buf, time2str(*ent->valid_start), sizeof(buf));
|
||||
strlcat(buf, time2str(*ent->valid_start), sizeof(buf));
|
||||
else
|
||||
strcat_truncate(buf, "-", sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, "-", sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
|
||||
/* --- valid end */
|
||||
if(ent->valid_end)
|
||||
strcat_truncate(buf, time2str(*ent->valid_end), sizeof(buf));
|
||||
strlcat(buf, time2str(*ent->valid_end), sizeof(buf));
|
||||
else
|
||||
strcat_truncate(buf, "-", sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, "-", sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
|
||||
/* --- password ends */
|
||||
if(ent->pw_end)
|
||||
strcat_truncate(buf, time2str(*ent->pw_end), sizeof(buf));
|
||||
strlcat(buf, time2str(*ent->pw_end), sizeof(buf));
|
||||
else
|
||||
strcat_truncate(buf, "-", sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, "-", sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
|
||||
/* --- max life */
|
||||
if(ent->max_life){
|
||||
asprintf(&p, "%d", *ent->max_life);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
free(p);
|
||||
}else
|
||||
strcat_truncate(buf, "-", sizeof(buf));
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, "-", sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
|
||||
/* --- max renewable life */
|
||||
if(ent->max_renew){
|
||||
asprintf(&p, "%d", *ent->max_renew);
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
free(p);
|
||||
}else
|
||||
strcat_truncate(buf, "-", sizeof(buf));
|
||||
strlcat(buf, "-", sizeof(buf));
|
||||
|
||||
strcat_truncate(buf, " ", sizeof(buf));
|
||||
strlcat(buf, " ", sizeof(buf));
|
||||
|
||||
/* --- flags */
|
||||
asprintf(&p, "%d", HDBFlags2int(ent->flags));
|
||||
strcat_truncate(buf, p, sizeof(buf));
|
||||
strlcat(buf, p, sizeof(buf));
|
||||
free(p);
|
||||
|
||||
*str = strdup(buf);
|
||||
|
@@ -309,8 +309,8 @@ ipv6_print_addr (const krb5_address *addr, char *str, size_t len)
|
||||
for(i = 0; i < addr->address.length; i++) {
|
||||
snprintf(buf2, sizeof(buf2), "%02x", p[i]);
|
||||
if(i > 0 && (i & 1) == 0)
|
||||
strcat_truncate(buf, ":", sizeof(buf));
|
||||
strcat_truncate(buf, buf2, sizeof(buf));
|
||||
strlcat(buf, ":", sizeof(buf));
|
||||
strlcat(buf, buf2, sizeof(buf));
|
||||
}
|
||||
}
|
||||
return snprintf(str, len, "IPv6:%s", buf);
|
||||
|
@@ -251,7 +251,7 @@ fkt_get_name(krb5_context context,
|
||||
{
|
||||
/* This function is XXX */
|
||||
struct fkt_data *d = id->data;
|
||||
strcpy_truncate(name, d->filename, namesize);
|
||||
strlcpy(name, d->filename, namesize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -168,7 +168,7 @@ akf_get_name(krb5_context context,
|
||||
{
|
||||
struct akf_data *d = id->data;
|
||||
|
||||
strcpy_truncate (name, d->filename, name_sz);
|
||||
strlcpy (name, d->filename, name_sz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,7 @@ krb4_kt_get_name (krb5_context context,
|
||||
{
|
||||
struct krb4_kt_data *d = id->data;
|
||||
|
||||
strcpy_truncate (name, d->filename, name_sz);
|
||||
strlcpy (name, d->filename, name_sz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,7 @@ krb5_sock_to_principal (krb5_context context,
|
||||
|
||||
if (hostent == NULL)
|
||||
return h_errno;
|
||||
strcpy_truncate(hname, hostent->h_name, sizeof(hname));
|
||||
strlcpy(hname, hostent->h_name, sizeof(hname));
|
||||
return krb5_sname_to_principal (context,
|
||||
hname,
|
||||
sname,
|
||||
|
Reference in New Issue
Block a user