On Tue, 2013-04-23 at 14:23 +0200, Daniel Wagner wrote: > From: Daniel Wagner <daniel.wag...@bmw-carit.de> > > g_strplit() will eventually strdup the tokens so no need to > strdup() 'context'. But we an ugly cast (from 'const unsigned char *' > to 'const char *') is needed for g_strsplit() to make the compiler happy. > --- > plugins/session_policy_local.c | 21 +++++++-------------- > 1 file changed, 7 insertions(+), 14 deletions(-) > > diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c > index 0b5f5ee..8140c0c 100644 > --- a/plugins/session_policy_local.c > +++ b/plugins/session_policy_local.c > @@ -73,9 +73,9 @@ static void cleanup_policy(gpointer user_data) > g_free(policy); > } > > -static char *parse_ident(const unsigned char *context) > +static char *parse_selinux_type(const char *context) > { > - char *str, *ident, **tokens; > + char *ident, **tokens; > > /* > * SELinux combines Role-Based Access Control (RBAC), Type > @@ -95,23 +95,14 @@ static char *parse_ident(const unsigned char *context) > * as haifux_t. > */ > > - str = g_strdup((const gchar*)context); > - if (str == NULL) > + tokens = g_strsplit(context, ":", 0); > + if (g_strv_length(tokens) < 2)
g_strfreev(tokens) here. > return NULL; > > - DBG("SELinux context %s", str); > - > - tokens = g_strsplit(str, ":", 0); > - if (tokens == NULL) { > - g_free(str); > - return NULL; > - } > - > /* Use the SELinux type as identification token. */ > ident = g_strdup(tokens[2]); > > g_strfreev(tokens); > - g_free(str); > > return ident; > } > @@ -167,7 +158,9 @@ static void selinux_context_reply(const unsigned char > *context, void *user_data, > if (err < 0) > goto done; > > - ident = parse_ident(context); > + DBG("SELinux context %s", context); > + > + ident = parse_selinux_type((const char*)context); > if (ident == NULL) { > err = -EINVAL; > goto done; _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman