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:
Assar Westerlund
1999-09-16 21:39:11 +00:00
parent bf75fac82a
commit d3f5d79294
15 changed files with 52 additions and 48 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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,