pts: add some sanity checks in ptuser.c 68/11668/4
authorBenjamin Kaduk <kaduk@mit.edu>
Wed, 14 Jan 2015 02:39:57 +0000 (21:39 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 5 Dec 2016 01:52:42 +0000 (20:52 -0500)
Double-check that when we're expecting two entries back, we
actually got two entries, in addition to the RPC return value.

Change-Id: I34631ac542667c337ed3268153eb61c70e3fa87e
Reviewed-on: https://gerrit.openafs.org/11668
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/ptserver/ptuser.c

index 6296cb4..7df9291 100644 (file)
@@ -444,6 +444,10 @@ pr_AddToGroup(prname user, prname group)
     if (code)
        goto done;
     /* if here, still could be missing an entry */
+    if (lids.idlist_len != 2) {
+       code = PRINTERNAL;
+       goto done;
+    }
     if (lids.idlist_val[0] == ANONYMOUSID
        || lids.idlist_val[1] == ANONYMOUSID) {
        code = PRNOENT;
@@ -483,6 +487,10 @@ pr_RemoveUserFromGroup(prname user, prname group)
     if (code)
        goto done;
 
+    if (lids.idlist_len != 2) {
+       code = PRINTERNAL;
+       goto done;
+    }
     if (lids.idlist_val[0] == ANONYMOUSID
        || lids.idlist_val[1] == ANONYMOUSID) {
        code = PRNOENT;
@@ -988,6 +996,11 @@ pr_IsAMemberOf(prname uname, prname gname, afs_int32 *flag)
        xdr_free((xdrproc_t) xdr_idlist, &lids);
        return code;
     }
+    if (lids.idlist_len != 2) {
+       free(lnames.namelist_val);
+       xdr_free((xdrproc_t) xdr_idlist, &lids);
+       return PRINTERNAL;
+    }
     code =
        ubik_PR_IsAMemberOf(pruclient, 0, lids.idlist_val[0],
                  lids.idlist_val[1], flag);