lkml.org 
[lkml]   [2015]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 5/5] selinux: use sprintf return value
From
Date
On 09/25/2015 06:34 PM, Rasmus Villemoes wrote:
> sprintf returns the number of characters printed (excluding '\0'), so
> we can use that and avoid duplicating the length computation.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Acked-by: Stephen Smalley <sds@tycho.nsa.gov>

> ---
> security/selinux/ss/services.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
> index aa2bdcb20848..ebb5eb3c318c 100644
> --- a/security/selinux/ss/services.c
> +++ b/security/selinux/ss/services.c
> @@ -1218,13 +1218,10 @@ static int context_struct_to_string(struct context *context, char **scontext, u3
> /*
> * Copy the user name, role name and type name into the context.
> */
> - sprintf(scontextp, "%s:%s:%s",
> + scontextp += sprintf(scontextp, "%s:%s:%s",
> sym_name(&policydb, SYM_USERS, context->user - 1),
> sym_name(&policydb, SYM_ROLES, context->role - 1),
> sym_name(&policydb, SYM_TYPES, context->type - 1));
> - scontextp += strlen(sym_name(&policydb, SYM_USERS, context->user - 1)) +
> - 1 + strlen(sym_name(&policydb, SYM_ROLES, context->role - 1)) +
> - 1 + strlen(sym_name(&policydb, SYM_TYPES, context->type - 1));
>
> mls_sid_to_context(context, &scontextp);
>
>



\
 
 \ /
  Last update: 2015-09-29 20:41    [W:0.169 / U:1.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site