diff options
author | Theodore Tso <tytso@mit.edu> | 1991-03-29 14:53:26 +0000 |
---|---|---|
committer | Theodore Tso <tytso@mit.edu> | 1991-03-29 14:53:26 +0000 |
commit | d54f7c390304abba83886234e2ee03d35b2f07b0 (patch) | |
tree | a3a40cf9433750e204e49a399a8058fef6578309 /src/lib | |
parent | 64d420d4f1bad747b6e08a28d3ca3abb28681677 (diff) | |
download | krb5-d54f7c390304abba83886234e2ee03d35b2f07b0.tar.gz krb5-d54f7c390304abba83886234e2ee03d35b2f07b0.tar.xz krb5-d54f7c390304abba83886234e2ee03d35b2f07b0.zip |
Changed rc_dfl_resolve to initlize the private data, instead of rc_initalize
or rc_recover. This means that caller must call rc_close after
calling rc_dfl_resolve. This change was required in order to prevent
a memory leak in rc_dfl_resolve, since it was doing some memory allocation
already; it now does all necessary memory allocation, and rc_close
frees all of the memory used by rc_dfl_resolve.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1972 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/krb5/rcache/rc_dfl.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c index c1efcd7df..de91d4db1 100644 --- a/src/lib/krb5/rcache/rc_dfl.c +++ b/src/lib/krb5/rcache/rc_dfl.c @@ -22,7 +22,7 @@ static char rcsid_rc_base_c[] = #include "rc_base.h" #include "rc_dfl.h" #include "rc_io.h" -#include <krb5/libos-proto.h> +#include <krb5/los-proto.h> /* If NOIOSTUFF is defined at compile time, dfl rcaches will be per-process. @@ -203,7 +203,6 @@ krb5_rcache id; krb5_deltat lifespan; { struct dfl_data *t = (struct dfl_data *)id->data; - int i; t->lifespan = lifespan; #ifndef NOIOSTUFF @@ -212,13 +211,6 @@ krb5_deltat lifespan; if (krb5_rc_io_write(&t->d,(krb5_pointer) &t->lifespan,sizeof(t->lifespan))) return KRB5_RC_IO; #endif - t->numhits = t->nummisses = 0; - t->hsize = HASHSIZE; /* could be variable, but naaaah */ - if (!(t->h = (struct authlist **) malloc(t->hsize*sizeof(struct authlist *)))) - return KRB5_RC_MALLOC; - for (i = 0;i < t->hsize;i++) - t->h[i] = (struct authlist *) 0; - t->a = (struct authlist *) 0; return 0; } @@ -237,7 +229,8 @@ krb5_rcache id; FREE(q); } #ifndef NOIOSTUFF - (void) krb5_rc_io_close(&t->d); + if (t->d.fd >= 0) + (void) krb5_rc_io_close(&t->d); #endif FREE(t); return 0; @@ -258,12 +251,23 @@ krb5_rcache id; char *name; { struct dfl_data *t; + int i; /* allocate id? no */ if (!(t = (struct dfl_data *) malloc(sizeof(struct dfl_data)))) return KRB5_RC_MALLOC; id->data = (krb5_pointer) t; t->name = name; /* gee, difficult... */ + t->numhits = t->nummisses = 0; + t->hsize = HASHSIZE; /* no need to store---it's memory-only */ + if (!(t->h = (struct authlist **) malloc(t->hsize*sizeof(struct authlist *)))) + return KRB5_RC_MALLOC; + for (i = 0;i < t->hsize;i++) + t->h[i] = (struct authlist *) 0; + t->a = (struct authlist *) 0; +#ifndef NOIOSTUFF + t->d.fd = -1; +#endif return 0; } @@ -285,15 +289,6 @@ krb5_rcache id; krb5_rc_io_close(&t->d); return KRB5_RC_IO; } - t->numhits = t->nummisses = 0; - t->hsize = HASHSIZE; /* no need to store---it's memory-only */ - if (!(t->h = (struct authlist **) malloc(t->hsize*sizeof(struct authlist *)))) { - krb5_rc_io_close(&t->d); - return KRB5_RC_MALLOC; - } - for (i = 0;i < t->hsize;i++) - t->h[i] = (struct authlist *) 0; - t->a = (struct authlist *) 0; /* now read in each auth_replay and insert into table */ for (;;) |