Fix: allow CIPSO labels with zero categories
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 8 Oct 2013 13:17:23 +0000 (16:17 +0300)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 14 Oct 2013 10:00:02 +0000 (13:00 +0300)
There was false restriction in smack_cipso_add_from_file() that
disallowed CIPSO labels without categories.

For example, this example given in the SMACK kernel documentation
should be perfectly legal:

TopSecret 7
(cherry picked from commit 4e4ea9142727ca7f14bf1d64cd81949b28bb1d0b)

libsmack/libsmack.c

index ac58dd2..1adc68e 100644 (file)
@@ -437,7 +437,7 @@ int smack_cipso_add_from_file(struct smack_cipso *cipso, int fd)
                label = strtok_r(buf, " \t\n", &ptr);
                level = strtok_r(NULL, " \t\n", &ptr);
                cat = strtok_r(NULL, " \t\n", &ptr);
-               if (label == NULL || cat == NULL || level == NULL ||
+               if (label == NULL || level == NULL ||
                    strlen(label) > SMACK_LABEL_LEN) {
                        errno = EINVAL;
                        goto err_out;