From ac582e7d51594cc8788694a2aa18c9758aa789d4 Mon Sep 17 00:00:00 2001 From: Bill Sommerfeld Date: Tue, 30 Jan 1990 15:38:53 +0000 Subject: [PATCH] Avoid copying ops structure git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@198 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/file/fcc_reslv.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/lib/krb5/ccache/file/fcc_reslv.c b/src/lib/krb5/ccache/file/fcc_reslv.c index b4c2e3a5b..a0f83c676 100644 --- a/src/lib/krb5/ccache/file/fcc_reslv.c +++ b/src/lib/krb5/ccache/file/fcc_reslv.c @@ -51,36 +51,28 @@ krb5_fcc_resolve (id, residual) if (lid == NULL) return KRB5_NOMEM; - lid->ops = (krb5_cc_ops *) malloc(sizeof(krb5_cc_ops)); - if (lid->ops == NULL) { - free(lid); - return KRB5_NOMEM; - } - + lid->ops = &krb5_fcc_ops; + lid->data = (krb5_fcc_data *) malloc(sizeof(krb5_fcc_data)); if (((krb5_fcc_data *) lid->data) == NULL) { - free(lid->ops); free(lid); return KRB5_NOMEM; } ((krb5_fcc_data *) lid->data)->filename = (char *) malloc(strlen(residual) + 1); + if (((krb5_fcc_data *) lid->data)->filename == NULL) { free(((krb5_fcc_data *) lid->data)); - free(lid->ops); free(lid); return KRB5_NOMEM; } - /* Copy the virtual operation pointers into lid */ - bcopy((char *) &krb5_fcc_ops, lid->ops, sizeof(krb5_cc_ops)); - /* Set up the filename */ strcpy(((krb5_fcc_data *) lid->data)->filename, residual); - /* Make sure the file name is reserved */ - ret = open(((krb5_fcc_data *) lid->data)->filename, O_CREAT|O_EXCL,0600); + /* Make sure we can open the file name */ + ret = open(((krb5_fcc_data *) lid->data)->filename, O_CREAT|O_RDWR,0600); if (ret == -1) return errno; else { -- 2.26.2