From 7d5a0d5b2387ac74fd984c63124822d13ec403e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Thu, 23 Jan 2014 11:04:50 +0100 Subject: [PATCH] Fix bug in cipso written rules MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The label (either short or long) was followed by a null character. It is now followed by a space. Note that the format for cipso2 smackfs is "%s?%4d%4d..." where ? stands for any invalid label character. Signed-off-by: José Bollo --- libsmack/libsmack.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libsmack/libsmack.c b/libsmack/libsmack.c index bc84fc4..005c913 100644 --- a/libsmack/libsmack.c +++ b/libsmack/libsmack.c @@ -385,9 +385,8 @@ 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, use_long ? "%s" : "%-23s", - m->label); - offset = strlen(buf) + 1; + offset = (int)snprintf(buf, SMACK_LABEL_LEN + 1, + use_long ? "%s " : "%-23s ", m->label); sprintf(&buf[offset], CIPSO_NUM_LEN_STR, m->level); offset += NUM_LEN; -- 2.7.4