Fixed bug reported by Bill Sommerfeld where a missing byte-swap on a
authorTheodore Tso <tytso@mit.edu>
Thu, 15 Sep 1994 01:58:33 +0000 (01:58 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 15 Sep 1994 01:58:33 +0000 (01:58 +0000)
little-endian machine causes the delete operation fail.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4235 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/keytab/file/ChangeLog [new file with mode: 0644]
src/lib/krb5/keytab/file/ktf_util.c

diff --git a/src/lib/krb5/keytab/file/ChangeLog b/src/lib/krb5/keytab/file/ChangeLog
new file mode 100644 (file)
index 0000000..28a8435
--- /dev/null
@@ -0,0 +1,6 @@
+Wed Sep 14 21:56:15 1994  Theodore Y. Ts'o  (tytso@dcl)
+
+       * ktf_util.c (krb5_ktfileint_delete_entry):  Fixed bug reported by
+               Bill Sommerfeld where a missing byte-swap on a
+               little-endian machine causes the delete operation fail.
+
index d5d04083f1604cc41c79eede05e40717860f3e54..94d0daaadcccbdbd61823375c7cd81c3463f6902 100644 (file)
@@ -205,16 +205,22 @@ krb5_int32 delete_point;
     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) {
-        size = -size;
+        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(&size, sizeof(size), 1, KTFILEP(id))) {
+
+        if (!xfwrite(&minus_size, sizeof(minus_size), 1, KTFILEP(id))) {
             return KRB5_KT_IOERR;
         }
 
-        size = -size;
         if (size < BUFSIZ) {
             len = size;
         } else {