pt_util: Protect against corrupt input files
[openafs.git] / src / ptserver / pt_util.c
index f1e9c39..a69e0b4 100644 (file)
@@ -234,6 +234,7 @@ CommandProc(struct cmd_syndesc *a_as, void *arock)
 
        while (fgets(buffer, sizeof(buffer), dfp)) {
            int id, oid, cid, flags, quota, uid;
+           int seenGroup = 0;
            char name[PR_MAXNAMELEN], mem[PR_MAXNAMELEN];
 
            if (isspace(*buffer)) {
@@ -244,6 +245,13 @@ CommandProc(struct cmd_syndesc *a_as, void *arock)
                    exit(1);
                }
 
+               if (!seenGroup) {
+                   fprintf(stderr,
+                           "Group member %s listed outside of group\n",
+                           mem);
+                   exit(1);
+               }
+
                for (u = usr_head; u; u = u->next)
                    if (u->uid && u->uid == uid)
                        break;
@@ -300,6 +308,8 @@ CommandProc(struct cmd_syndesc *a_as, void *arock)
                    exit(1);
                }
 
+               seenGroup = 1;
+
                if (FindByID(0, id))
                    code = PRIDEXIST;
                else