static int accesses_apply(struct smack_accesses *handle, int clear);
static inline void parse_access_type(const char *in, char out[ACC_LEN + 1]);
-static int smack_label_length(const char *label) __attribute__((unused));
+static ssize_t smack_label_length(const char *label) __attribute__((unused));
+static inline ssize_t get_label(char *dest, const char *src);
int smack_accesses_new(struct smack_accesses **accesses)
{
return (ret < 0) ? -1 : 0;
}
+ssize_t smack_label_length(const char *label)
+{
+ return get_label(NULL, label);
+}
+
static int accesses_apply(struct smack_accesses *handle, int clear)
{
char buf[LOAD_LEN + 1];
}
}
-static int smack_label_length(const char *label)
+static inline ssize_t get_label(char *dest, const char *src)
{
int i;
- if (!label || label[0] == '\0' || label[0] == '-')
+ if (!src || src[0] == '\0' || src[0] == '-')
return -1;
- for (i = 0; i < (SMACK_LABEL_LEN + 1) && label[i]; i++) {
- switch (label[i]) {
+ for (i = 0; i < (SMACK_LABEL_LEN + 1) && src[i]; i++) {
+ switch (src[i]) {
case ' ':
case '/':
case '"':
default:
break;
}
+
+ if (dest)
+ dest[i] = src[i];
}
+ if (i < (SMACK_LABEL_LEN + 1))
+ dest[i] = '\0';
+
return i < (SMACK_LABEL_LEN + 1) ? i : -1;
}