Use asprintf for string construction
[openafs.git] / src / ptserver / db_verify.c
index 8ed2f85..6a04ab1 100644 (file)
@@ -1,16 +1,17 @@
 /*
  * 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>
+#include <afs/stds.h>
 
+#include <roken.h>
 
 /*
  *                      (3) Define a structure, idused, instead of an
  *                          conditions.
  */
 
-#include <afs/stds.h>
-#include <sys/types.h>
+
 #ifdef AFS_NT40_ENV
-#include <winsock2.h>
 #include <WINNT/afsevent.h>
-#include <io.h>
 #else
-#include <netdb.h>
-#include <netinet/in.h>
 #include <sys/file.h>
 #endif
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
+
 #include <afs/cellconfig.h>
 #include <afs/afsutil.h>
 #include <ubik.h>
@@ -217,7 +210,7 @@ readUbikHeader(struct misc_data *misc)
     }
 
     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);
 
@@ -931,12 +924,12 @@ GC(char map[], struct misc_data *misc)
            id = ntohl(e.id);
 #if defined(SUPERGROUPS)
            if ((id != ANONYMOUSID)
-               && ((refCount = idcount(&misc->idmap, id)) != ntohl(e.count))) 
+               && ((refCount = idcount(&misc->idmap, id)) != ntohl(e.count)))
 #else
            if ((id >= misc->minId) && (id <= misc->maxId)
                && (id != ANONYMOUSID)
                && ((refCount = misc->idmap[id - misc->minId]) !=
-                   ntohl(e.count))) 
+                   ntohl(e.count)))
 #endif /* SUPERGROUPS */
              {
                afs_int32 na;
@@ -969,10 +962,7 @@ QuoteName(char *s)
 {
     char *qs;
     if (strpbrk(s, " \t")) {
-       qs = (char *)malloc(strlen(s) + 3);
-       strcpy(qs, "\"");
-       strcat(qs, s);
-       strcat(qs, "\"");
+       asprintf(&qs, "\"%s\"", s);
     } else
        qs = s;
     return qs;
@@ -1040,9 +1030,9 @@ DumpRecreate(char map[], struct misc_data *misc)
                /* check for duplicate id.  This may still lead to duplicate
                 * names. */
 #if defined(SUPERGROUPS)
-               if (idcount(&idmap, id)) 
+               if (idcount(&idmap, id))
 #else
-               if (idmap[id - misc->minId]) 
+               if (idmap[id - misc->minId])
 #endif
                  {
                    fprintf(stderr, "Skipping entry with duplicate id %di\n",
@@ -1151,9 +1141,9 @@ DumpRecreate(char map[], struct misc_data *misc)
 
            owner = ntohl(e.owner);
 #if defined(SUPERGROUPS)
-           if (!idcount(&idmap, owner)) 
+           if (!idcount(&idmap, owner))
 #else
-           if (idmap[owner - misc->minId] == 0) 
+           if (idmap[owner - misc->minId] == 0)
 #endif
              {
                fprintf(stderr,
@@ -1383,7 +1373,7 @@ CheckPrDatabase(struct misc_data *misc)   /* info & statistics */
     free(map);
     return code;
 }
-    
+
 #include "AFS_component_version_number.c"
 
 int