[krbdev.mit.edu #3549] Better patch

Russ Allbery via RT rt-comment at krbdev.mit.edu
Sun Apr 23 15:23:53 EDT 2006


Here is a better patch, almost identical to the patch by Rainer Weikusat
in RT #3685.  I use KRB5_KEYTAB_BADVNO as the return for this case,
similar to the code immediately below, rather than using KRB5_KT_END.  I
can see arguments for either.

Committed to the Debian source tree, although not in any uploaded version
yet.

% touch keytab
% klist -k keytab
Keytab name: FILE:keytab
KVNO Principal
---- --------------------------------------------------------------------------
*** glibc detected *** double free or corruption (!prev): 0x0804d6a8 ***
Abort
% env LD_LIBRARY_PATH=libkrb53/usr/lib klist -k keytab 
Keytab name: FILE:keytab
klist: Unsupported key table format version number while starting keytab scan


--- krb5-1.4.3.orig/src/lib/krb5/keytab/kt_file.c
+++ krb5-1.4.3/src/lib/krb5/keytab/kt_file.c
@@ -1107,7 +1107,10 @@
     } else {
 	/* gotta verify it instead... */
 	if (!xfread(&kt_vno, sizeof(kt_vno), 1, KTFILEP(id))) {
-	    kerror = errno;
+	    if (feof(KTFILEP(id)))
+		kerror = KRB5_KEYTAB_BADVNO;
+	    else
+		kerror = errno;
 	    (void) krb5_unlock_file(context, fileno(KTFILEP(id)));
 	    (void) fclose(KTFILEP(id));
 	    return kerror;

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>




More information about the krb5-bugs mailing list