aboutsummaryrefslogtreecommitdiff
path: root/src/kadmin/cli/kadmin.c
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2008-12-01 17:09:59 +0000
committerGreg Hudson <ghudson@mit.edu>2008-12-01 17:09:59 +0000
commit0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b (patch)
tree3ab0a7b22c93fd929b1f532e98618d62f1a848d9 /src/kadmin/cli/kadmin.c
parent689e929e5e0240684408bb0bc53d536f5696cdea (diff)
downloadkrb5-0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b.zip
krb5-0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b.tar.gz
krb5-0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b.tar.bz2
Convert many uses of sprintf to snprintf or asprintf
ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21258 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kadmin/cli/kadmin.c')
-rw-r--r--src/kadmin/cli/kadmin.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c
index 00f26b1..125310f 100644
--- a/src/kadmin/cli/kadmin.c
+++ b/src/kadmin/cli/kadmin.c
@@ -134,9 +134,9 @@ static char *strdur(duration)
minutes = duration / 60;
duration %= 60;
seconds = duration;
- sprintf(out, "%s%d %s %02d:%02d:%02d", neg ? "-" : "",
- days, days == 1 ? "day" : "days",
- hours, minutes, seconds);
+ snprintf(out, sizeof(out), "%s%d %s %02d:%02d:%02d", neg ? "-" : "",
+ days, days == 1 ? "day" : "days",
+ hours, minutes, seconds);
return out;
}
@@ -794,11 +794,12 @@ void kadmin_cpw(argc, argv)
} else if (argc == 1) {
unsigned int i = sizeof (newpw) - 1;
- sprintf(prompt1, "Enter password for principal \"%.900s\"",
- *argv);
- sprintf(prompt2,
- "Re-enter password for principal \"%.900s\"",
- *argv);
+ snprintf(prompt1, sizeof(prompt1),
+ "Enter password for principal \"%.900s\"",
+ *argv);
+ snprintf(prompt2, sizeof(prompt2),
+ "Re-enter password for principal \"%.900s\"",
+ *argv);
retval = krb5_read_password(context, prompt1, prompt2,
newpw, &i);
if (retval) {
@@ -1228,11 +1229,12 @@ void kadmin_addprinc(argc, argv)
} else if (pass == NULL) {
unsigned int sz = sizeof (newpw) - 1;
- sprintf(prompt1, "Enter password for principal \"%.900s\"",
- canon);
- sprintf(prompt2,
- "Re-enter password for principal \"%.900s\"",
- canon);
+ snprintf(prompt1, sizeof(prompt1),
+ "Enter password for principal \"%.900s\"",
+ canon);
+ snprintf(prompt2, sizeof(prompt2),
+ "Re-enter password for principal \"%.900s\"",
+ canon);
retval = krb5_read_password(context, prompt1, prompt2,
newpw, &sz);
if (retval) {
@@ -1513,14 +1515,14 @@ void kadmin_getprinc(argc, argv)
if (krb5_enctype_to_string(key_data->key_data_type[0],
enctype, sizeof(enctype)))
- sprintf(enctype, "<Encryption type 0x%x>",
- key_data->key_data_type[0]);
+ snprintf(enctype, sizeof(enctype), "<Encryption type 0x%x>",
+ key_data->key_data_type[0]);
printf("Key: vno %d, %s, ", key_data->key_data_kvno, enctype);
if (key_data->key_data_ver > 1) {
if (krb5_salttype_to_string(key_data->key_data_type[1],
salttype, sizeof(salttype)))
- sprintf(salttype, "<Salt type 0x%x>",
- key_data->key_data_type[1]);
+ snprintf(salttype, sizeof(salttype), "<Salt type 0x%x>",
+ key_data->key_data_type[1]);
printf("%s\n", salttype);
} else
printf("no salt\n");