ntohs ubik header size
[openafs.git] / src / kauth / rebuild.c
index 84d4ae7..6794d9d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <fcntl.h>
-#include <io.h>
-#else
-#include <sys/file.h>
-#include <netinet/in.h>
-#endif
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <time.h>
+#include <roken.h>
+
+#include <hcrypto/des.h>
+
 #include <ubik.h>
 #include <afs/cmd.h>
-
+#include <rx/rxkad.h>
 #include <afs/com_err.h>
 
 #include "kauth.h"
@@ -62,13 +49,13 @@ readUbikHeader(void)
     /* now read the info */
     r = read(fd, &uheader, sizeof(uheader));
     if (r != sizeof(uheader)) {
-       printf("error: read of %lu bytes failed: %d %d\n", sizeof(uheader), r,
+       printf("error: read of %" AFS_SIZET_FMT " bytes failed: %d %d\n", sizeof(uheader), r,
               errno);
        return (-1);
     }
 
     uheader.magic = ntohl(uheader.magic);
-    uheader.size = ntohl(uheader.size);
+    uheader.size = ntohs(uheader.size);
     uheader.version.epoch = ntohl(uheader.version.epoch);
     uheader.version.counter = ntohl(uheader.version.counter);
 
@@ -330,7 +317,7 @@ CheckHeader(struct kaheader *header)
     if (header->headerSize != sizeof(struct kaheader)) {
        code++;
        fprintf(stderr,
-               "HEADER SIZE WRONG: file indicates %d, should be %d\n",
+               "HEADER SIZE WRONG: file indicates %d, should be %" AFS_SIZET_FMT "\n",
                header->headerSize, sizeof(struct kaheader));
     }
     if (header->hashsize != HASHSIZE) {
@@ -436,7 +423,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
     if ((info.st_size - UBIK_HEADERSIZE) % UBIK_BUFFERSIZE)
        fprintf(stderr,
                "DATABASE SIZE INCONSISTENT: was %d, should be (n*%d + %d), for integral n\n",
-               info.st_size, UBIK_BUFFERSIZE, UBIK_HEADERSIZE);
+               (int) info.st_size, UBIK_BUFFERSIZE, UBIK_HEADERSIZE);
 
     readUbikHeader();
 
@@ -469,8 +456,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                    printf("Entry %d has zero length name\n", i);
                continue;
            }
-           if (!des_check_key_parity(&entry.key)
-               || des_is_weak_key(&entry.key)) {
+           if (!DES_check_key_parity(ktc_to_cblock(&entry.key))
+               || DES_is_weak_key(ktc_to_cblock(&entry.key))) {
                fprintf(stderr, "Entry %d, %s, has bad key\n", i,
                        EntryName(&entry));
                continue;
@@ -503,7 +490,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
            i = NameHash(&entry);
            if (i != j) {
                fprintf(stderr,
-                       "Entry %d, %s, found in hash chain %d (should be %d)\n",
+                       "Entry %" AFS_SIZET_FMT ", %s, found in hash chain %d (should be %d)\n",
                        ((index -
                          sizeof(struct kaheader)) / sizeof(struct kaentry)),
                        EntryName(&entry), j, i);