only allocate as much space as we need
authorJohn Kohl <jtkohl@mit.edu>
Thu, 18 Apr 1991 16:40:22 +0000 (16:40 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Thu, 18 Apr 1991 16:40:22 +0000 (16:40 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1994 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/ccache/file/fcc_gennew.c
src/lib/krb5/ccache/stdio/scc_gennew.c

index 063091f13ac2f52abe1b1dbfd0e7308ec3daa323..6995605e123a19a066e66994be626bb22714b992 100644 (file)
@@ -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));
index 42dc6d6024585158251b255162b9a673af2de882..cbe41f5a920347bf758a870f5a0281a89ad110f2 100644 (file)
@@ -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));