ptserver: Use correct structure type in malloc
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 12 Feb 2013 13:54:18 +0000 (13:54 +0000)
committerJeffrey Altman <jaltman@your-file-system.com>
Thu, 21 Feb 2013 17:09:01 +0000 (09:09 -0800)
prentries is a list of 'struct prlistentries' objects, not a list of
'struct prentry'. Use the correct type in our call to malloc.

Caught by clang analyzer

Change-Id: I6c36e4b875eafb8aff6506cf800d47b45a79825d
Reviewed-on: http://gerrit.openafs.org/9150
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/ptserver/ptprocs.c

index cf31d76..776a67b 100644 (file)
@@ -1479,7 +1479,7 @@ put_prentries(struct prentry *tentry, prentries *bulkentries)
     if (bulkentries->prentries_val == 0) {
        bulkentries->prentries_len = 0;
        bulkentries->prentries_val = malloc(PR_MAXENTRIES *
-                                           sizeof(struct prentry));
+                                           sizeof(struct prlistentries));
        if (!bulkentries->prentries_val) {
            return (PRNOMEM);
        }
@@ -1489,7 +1489,7 @@ put_prentries(struct prentry *tentry, prentries *bulkentries)
        return (-1);
     }
 
-    entry = (struct prlistentries *)bulkentries->prentries_val;
+    entry = bulkentries->prentries_val;
     entry += bulkentries->prentries_len;
 
     entry->flags = tentry->flags >> PRIVATE_SHIFT;