From fecfae9d661ca0df818aee99644123700caea610 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Mon, 11 Feb 1991 16:04:47 +0000 Subject: [PATCH] add vno code; plug file descriptor leaks git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1661 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/rcache/rc_io.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/lib/krb5/rcache/rc_io.c b/src/lib/krb5/rcache/rc_io.c index d9d440a60..3a61140ba 100644 --- a/src/lib/krb5/rcache/rc_io.c +++ b/src/lib/krb5/rcache/rc_io.c @@ -19,6 +19,9 @@ static char rcsid_rc_base_c[] = * I/O functions for the replay cache default implementation. */ + +#define KRB5_RC_VNO 0x0501 /* krb5, rcache v 1 */ + #include /* for P_tmpdir */ #include "rc_base.h" @@ -60,6 +63,8 @@ krb5_rc_iostuff *d; char **fn; { char *c; + krb5_int16 rc_vno = htons(KRB5_RC_VNO); + krb5_error_code retval; GETDIR; if (fn && *fn) @@ -114,6 +119,12 @@ char **fn; case EROFS: FREE(d->fn); return KRB5_RC_IO_PERM; break; default: FREE(d->fn); return KRB5_RC_IO_UNKNOWN; break; } + if (retval = krb5_rc_io_write(d, (krb5_pointer)&rc_vno, sizeof(rc_vno))) { + (void) unlink(d->fn); + FREE(d->fn); + (void) close(d->fd); + return retval; + } return 0; } @@ -121,6 +132,8 @@ krb5_error_code krb5_rc_io_open (d, fn) krb5_rc_iostuff *d; char *fn; { + krb5_int16 rc_vno; + krb5_error_code retval; GETDIR; if (!(d->fn = malloc(strlen(fn) + dirlen + 1))) return KRB5_RC_IO_MALLOC; @@ -143,6 +156,17 @@ char *fn; case EROFS: FREE(d->fn); return KRB5_RC_IO_PERM; break; default: FREE(d->fn); return KRB5_RC_IO_UNKNOWN; break; } + if (retval = krb5_rc_io_read(d, (krb5_pointer) &rc_vno, sizeof(rc_vno))) { + (void) close(d->fd); + FREE(d->fn); + return retval; + } + if (ntohs(rc_vno) != KRB5_RC_VNO) { + (void) close(d->fd); + FREE(d->fn); + return KRB5_RCACHE_BADVNO; + } + return 0; } -- 2.26.2