[1195] in Kerberos-V5-bugs
freeing in clients directories
daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Sat Mar 18 21:45:39 1995
From: epeisach@MIT.EDU
Date: Sat, 18 Mar 1995 21:45:19 -0500
To: krb5-bugs@MIT.EDU
I decided to test out a malloc debugger and I thought I would see how
'broken' the simple client code was in freeing memory when finished. Yes
- I know this isn;t necessary, but I wanted to see what needed to be
done and by whom...
You can take it or leave it... The only think that realy should get in
is the the klist usage...
Ezra
===================================================================
RCS file: /mit/krb5/.cvsroot/src/clients/kdestroy/kdestroy.c,v
retrieving revision 5.12
diff -c -r5.12 kdestroy.c
*** kdestroy.c 1995/02/28 10:12:16 5.12
--- kdestroy.c 1995/03/19 01:33:38
***************
*** 27,32 ****
--- 27,33 ----
#include <stdio.h>
#include "krb5.h"
+ #include "ext-proto.h"
#include "com_err.h"
extern int optind;
***************
*** 92,98 ****
--- 93,104 ----
}
}
+ /* cache is freed in next call */
code = krb5_cc_destroy (kcontext, cache);
+
+
+ krb5_free_context(kcontext);
+
if (code != 0) {
com_err (argv[0], code, "while destroying cache");
if (quiet)
===================================================================
RCS file: /mit/krb5/.cvsroot/src/clients/kinit/kinit.c,v
retrieving revision 5.35
diff -c -r5.35 kinit.c
*** kinit.c 1995/02/28 10:12:20 5.35
--- kinit.c 1995/03/19 02:03:40
***************
*** 29,34 ****
--- 29,35 ----
#include <pwd.h>
#include "krb5.h"
+ #include "ext-proto.h"
#define KRB5_DEFAULT_OPTIONS 0
#define KRB5_DEFAULT_LIFE 60*60*8 /* 8 hours */
***************
*** 272,280 ****
&my_creds, 0);
}
! krb5_free_principal(kcontext, server);
krb5_free_addresses(kcontext, my_addresses);
!
if (code) {
if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
fprintf (stderr, "%s: Password incorrect\n", argv[0]);
--- 273,286 ----
&my_creds, 0);
}
!
! free(client_name);
! /* This will free 'server', and 'me' which are pointed to by my_creds */
! krb5_free_cred_contents(kcontext, &my_creds);
krb5_free_addresses(kcontext, my_addresses);
! (void) krb5_cc_close(kcontext, ccache);
! krb5_free_context(kcontext);
!
if (code) {
if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
fprintf (stderr, "%s: Password incorrect\n", argv[0]);
===================================================================
RCS file: /mit/krb5/.cvsroot/src/clients/klist/klist.c,v
retrieving revision 5.21
diff -c -r5.21 klist.c
*** klist.c 1995/02/28 10:12:24 5.21
--- klist.c 1995/03/19 02:38:52
***************
*** 27,32 ****
--- 27,33 ----
#include <stdio.h>
#include "krb5.h"
#include "com_err.h"
+ #include "ext-proto.h"
#include <time.h>
extern int optind;
***************
*** 101,107 ****
errflg++;
if (errflg) {
! fprintf(stderr, "Usage: %s [ -c cache ]\n", progname);
exit(2);
}
if (cache == NULL) {
--- 102,108 ----
errflg++;
if (errflg) {
! fprintf(stderr, "Usage: %s [-e] [-f] [ -c cache ]\n", progname);
exit(2);
}
if (cache == NULL) {
***************
*** 130,135 ****
--- 131,139 ----
com_err(progname, code, "while unparsing principal name");
exit(1);
}
+
+ krb5_free_principal(kcontext, princ);
+
printf("Ticket cache: %s\nDefault principal: %s\n\n",
krb5_cc_get_name(kcontext, cache), defname);
if (code = krb5_cc_start_seq_get(kcontext, cache, &cur)) {
***************
*** 149,162 ****
}
flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode */
if (code = krb5_cc_set_flags(kcontext, cache, flags)) {
! com_err(progname, code, "while closing ccache");
exit(1);
}
! exit(0);
} else {
com_err(progname, code, "while retrieving a ticket");
! exit(1);
}
}
char *
--- 153,177 ----
}
flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode */
if (code = krb5_cc_set_flags(kcontext, cache, flags)) {
! com_err(progname, code, "while closing ccache file");
exit(1);
}
! errflg = 0;
} else {
com_err(progname, code, "while retrieving a ticket");
! errflg = 1;
}
+
+ free(defname);
+
+ if (code = krb5_fcc_close(kcontext, cache)) {
+ com_err(progname, code, "while closing ccache");
+ errflg = 1;
+ }
+
+ krb5_free_context(kcontext);
+
+ exit(errflg);
}
char *