libsmack: fix smack_cipso_apply() failing with more than one rule
authorRafal Krypa <r.krypa@samsung.com>
Mon, 2 Dec 2013 15:03:28 +0000 (16:03 +0100)
committerRafal Krypa <r.krypa@samsung.com>
Mon, 2 Dec 2013 15:20:53 +0000 (16:20 +0100)
Fixing regression in f47b9c90 that causes smack_cipso_apply() to fail due
to a typo.

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
libsmack/libsmack.c

index 28218ac..843c7e5 100644 (file)
@@ -390,7 +390,7 @@ int smack_cipso_apply(struct smack_cipso *cipso)
        int fd;
        int i;
        char path[PATH_MAX];
-       int offset=0;
+       int offset;
 
        if (!smackfs_mnt)
                return -1;
@@ -403,7 +403,7 @@ int smack_cipso_apply(struct smack_cipso *cipso)
        memset(buf,0,CIPSO_MAX_SIZE);
        for (m = cipso->first; m != NULL; m = m->next) {
                snprintf(buf, SMACK_LABEL_LEN + 1, "%s", m->label);
-               offset += strlen(buf) + 1;
+               offset = strlen(buf) + 1;
 
                sprintf(&buf[offset], CIPSO_NUM_LEN_STR, m->level);
                offset += NUM_LEN;