diff --git a/ChangeLog b/ChangeLog index a0cb720dc..b9d209658 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +1999-09-16 Assar Westerlund + + * configure.in: test for strlcpy, strlcat + 1999-09-14 Assar Westerlund * lib/krb5/init_creds_pw.c (krb5_get_init_creds_password): return diff --git a/appl/kf/kfd.c b/appl/kf/kfd.c index c6487e9f6..1b9772c8c 100644 --- a/appl/kf/kfd.c +++ b/appl/kf/kfd.c @@ -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); diff --git a/appl/login/login.c b/appl/login/login.c index 8cc919260..a797d35fc 100644 --- a/appl/login/login.c +++ b/appl/login/login.c @@ -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; } } diff --git a/appl/rsh/rshd.c b/appl/rsh/rshd.c index c832149ca..3c8f0b8f5 100644 --- a/appl/rsh/rshd.c +++ b/appl/rsh/rshd.c @@ -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, diff --git a/kadmin/ank.c b/kadmin/ank.c index 0c33bcf9e..b3d70bd44 100644 --- a/kadmin/ank.c +++ b/kadmin/ank.c @@ -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)); diff --git a/kadmin/random_password.c b/kadmin/random_password.c index 87f5ca73b..3a64a474a 100644 --- a/kadmin/random_password.c +++ b/kadmin/random_password.c @@ -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 diff --git a/kadmin/version4.c b/kadmin/version4.c index 8ba4a4f6c..e494abfe1 100644 --- a/kadmin/version4.c +++ b/kadmin/version4.c @@ -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; diff --git a/kdc/hpropd.c b/kdc/hpropd.c index 689a068bf..f4b1e0680 100644 --- a/kdc/hpropd.c +++ b/kdc/hpropd.c @@ -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); diff --git a/kuser/klist.c b/kuser/klist.c index f1d120dea..58548cdf7 100644 --- a/kuser/klist.c +++ b/kuser/klist.c @@ -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); diff --git a/lib/hdb/print.c b/lib/hdb/print.c index 5a3133c99..d175d7bac 100644 --- a/lib/hdb/print.c +++ b/lib/hdb/print.c @@ -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); diff --git a/lib/krb5/addr_families.c b/lib/krb5/addr_families.c index 9faff907e..558656c13 100644 --- a/lib/krb5/addr_families.c +++ b/lib/krb5/addr_families.c @@ -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); diff --git a/lib/krb5/keytab_file.c b/lib/krb5/keytab_file.c index 1dae081a5..0e15ab1ea 100644 --- a/lib/krb5/keytab_file.c +++ b/lib/krb5/keytab_file.c @@ -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; } diff --git a/lib/krb5/keytab_keyfile.c b/lib/krb5/keytab_keyfile.c index 2b0c4259f..d19c64c1c 100644 --- a/lib/krb5/keytab_keyfile.c +++ b/lib/krb5/keytab_keyfile.c @@ -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; } diff --git a/lib/krb5/keytab_krb4.c b/lib/krb5/keytab_krb4.c index d9621fc96..12e354cd6 100644 --- a/lib/krb5/keytab_krb4.c +++ b/lib/krb5/keytab_krb4.c @@ -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; } diff --git a/lib/krb5/sock_principal.c b/lib/krb5/sock_principal.c index a5e213721..a9364c965 100644 --- a/lib/krb5/sock_principal.c +++ b/lib/krb5/sock_principal.c @@ -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,