[730] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

bug in keytab_delete on little-endian systems.

daemon@ATHENA.MIT.EDU (Bill Sommerfeld)
Fri Sep 9 13:34:15 1994

Date: Fri, 9 Sep 1994 13:34:02 -0400
From: Bill Sommerfeld <sommerfeld@apollo.hp.com>
To: krb5-bugs@MIT.EDU

if you attempt to delete an entry from a keytab on a little-endian
processor with a version 2 keytab, you get a full disk due to a missed
byte swap.

Here's a possible patch; YLNMV as always.

*** ktf_util.c~	Fri Sep  9 12:49:47 1994
--- ktf_util.c	Fri Sep  9 13:31:16 1994
***************
*** 245,260 ****
      if (!xfread(&size, sizeof(size), 1, KTFILEP(id))) {
          return KRB5_KT_END;
      }
      if (size > 0) {
!         size = -size;
          if (fseek(KTFILEP(id), delete_point, SEEK_SET)) {
              return errno;
          }
!         if (!xfwrite(&size, sizeof(size), 1, KTFILEP(id))) {
              return KRB5_KT_IOERR;
          }
  
-         size = -size;
          if (size < BUFSIZ) {
              len = size;
          } else {
--- 245,266 ----
      if (!xfread(&size, sizeof(size), 1, KTFILEP(id))) {
          return KRB5_KT_END;
      }
+     if (KTVERSION(id) != KRB5_KT_VNO_1)
+ 	size = ntohl(size);
+ 
      if (size > 0) {
!         krb5_int32 minus_size = -size;
! 	if (KTVERSION(id) != KRB5_KT_VNO_1)
! 	    minus_size = htonl(minus_size);
! 
          if (fseek(KTFILEP(id), delete_point, SEEK_SET)) {
              return errno;
          }
! 
!         if (!xfwrite(&minus_size, sizeof(minus_size), 1, KTFILEP(id))) {
              return KRB5_KT_IOERR;
          }
  
          if (size < BUFSIZ) {
              len = size;
          } else {

home help back first fref pref prev next nref lref last post