From: John Kohl Date: Thu, 18 Apr 1991 16:40:22 +0000 (+0000) Subject: only allocate as much space as we need X-Git-Tag: krb5-1.0-alpha5~107 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b4122bd1a0b95c4e09e6764e9c168b48ab833a3;p=krb5.git only allocate as much space as we need git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1994 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/file/fcc_gennew.c b/src/lib/krb5/ccache/file/fcc_gennew.c index 063091f13..6995605e1 100644 --- a/src/lib/krb5/ccache/file/fcc_gennew.c +++ b/src/lib/krb5/ccache/file/fcc_gennew.c @@ -42,7 +42,8 @@ krb5_fcc_generate_new (id) { krb5_ccache lid; int ret; - char scratch[100]; /* XXX Is this large enough */ + char scratch[sizeof(TKT_ROOT)+6+1]; /* +6 for the scratch part, +1 for + NUL */ /* Allocate memory */ lid = (krb5_ccache) malloc(sizeof(struct _krb5_ccache)); @@ -51,7 +52,8 @@ krb5_fcc_generate_new (id) lid->ops = &krb5_fcc_ops; - sprintf(scratch, "%sXXXXXX", TKT_ROOT); + (void) strcpy(scratch, TKT_ROOT); + (void) strcat(scratch, "XXXXXX"); mktemp(scratch); lid->data = (krb5_pointer) malloc(sizeof(krb5_fcc_data)); diff --git a/src/lib/krb5/ccache/stdio/scc_gennew.c b/src/lib/krb5/ccache/stdio/scc_gennew.c index 42dc6d602..cbe41f5a9 100644 --- a/src/lib/krb5/ccache/stdio/scc_gennew.c +++ b/src/lib/krb5/ccache/stdio/scc_gennew.c @@ -42,7 +42,8 @@ krb5_scc_generate_new (id) { krb5_ccache lid; FILE *f; - char scratch[100]; /* XXX Is this large enough */ + char scratch[sizeof(TKT_ROOT)+6+1]; /* +6 for the scratch part, +1 for + NUL */ /* Allocate memory */ lid = (krb5_ccache) malloc(sizeof(struct _krb5_ccache)); @@ -51,7 +52,8 @@ krb5_scc_generate_new (id) lid->ops = &krb5_scc_ops; - sprintf(scratch, "%sXXXXXX", TKT_ROOT); + (void) strcpy(scratch, TKT_ROOT); + (void) strcat(scratch, "XXXXXX"); mktemp(scratch); lid->data = (krb5_pointer) malloc(sizeof(krb5_scc_data));