summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rstsmack.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rstsmack.c b/src/rstsmack.c
index 38d18d5..8ca51e1 100644
--- a/src/rstsmack.c
+++ b/src/rstsmack.c
@@ -75,6 +75,7 @@ static int parse_and_set(const char *srcfile)
FILE *fp;
int ret = 0;
char linebuf[PATH_MAX + 5 * SMACK_LABEL_LEN], pathname[PATH_MAX];
+ size_t linebuf_len;
char label[SMACK_LABEL_LEN + 1];
char *plabel; /* pointer of beginning smack label */
fp = fopen(srcfile, "r");
@@ -89,7 +90,13 @@ static int parse_and_set(const char *srcfile)
pathname[sizeof(pathname) - 1] = '\0';
plabel++;
} else {
- linebuf[strlen(linebuf) - 1] = '\0';
+ linebuf_len = strlen(linebuf);
+ if (linebuf_len > 0 && linebuf_len <= sizeof(linebuf))
+ linebuf[linebuf_len - 1] = '\0';
+ else {
+ LOGINFO("Invalid label length (%u)\n", linebuf_len);
+ return -1;
+ }
LOGINFO("no label, set label: %s, access=\"_\"(floor)\n", linebuf);
strncpy(label, "_\"", SMACK_LABEL_LEN);
set_label(linebuf, label, SMACK_LABEL_ACCESS);