From: James Antill <james.antill@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Paul Moore <paul.moore@hp.com>, selinux@tycho.nsa.gov
Subject: Re: [RFC PATCH] SELinux: Cleanup the secid/secctx conversion functions
Date: Fri, 29 Feb 2008 11:40:55 -0500 [thread overview]
Message-ID: <1204303255.11268.326.camel@code.and.org> (raw)
In-Reply-To: <1204294426.31790.256.camel@moss-spartans.epoch.ncsc.mil>
[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]
On Fri, 2008-02-29 at 09:13 -0500, Stephen Smalley wrote:
> On Fri, 2008-02-29 at 08:54 -0500, Stephen Smalley wrote:
> > The snippet below looks like a step backward rather than an improvement
> > - single sprintf replaced by series of strcat calls. That can't be more
> > efficient.
>
> Hmm...well, maybe I'm wrong (after looking at the implementations).
> Pity that Linux doesn't have stpcpy (as in glibc) - that is much nicer
> than a series of strcat's since it returns the end pointer and doesn't
> require finding the end of string each time.
Note that you can do (only slightly abusing the interface):
ctx = *scontext;
ctx += strlcpy(ctx, policydb.p_user_val_to_name[context->user - 1], -1);
ctx += strlcpy(ctx, ":", -1);
ctx += strlcpy(ctx, policydb.p_role_val_to_name[context->role - 1], -1);
ctx += strlcpy(ctx, ":", -1);
ctx += strlcpy(ctx, policydb.p_type_val_to_name[context->type - 1], -1);
...which is basically a memcpy() with a simple if test.
> > > - *scontextp = 0;
> > > + ctx = *scontext;
> > > + strcpy(ctx, policydb.p_user_val_to_name[context->user - 1]);
> > > + strcat(ctx, ":");
> > > + strcat(ctx, policydb.p_role_val_to_name[context->role - 1]);
> > > + strcat(ctx, ":");
> > > + strcat(ctx, policydb.p_type_val_to_name[context->type - 1]);
> >
--
James Antill <james.antill@redhat.com>
Red Hat
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2008-02-29 16:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-28 21:41 [RFC PATCH] SELinux: Cleanup the secid/secctx conversion functions Paul Moore
2008-02-29 9:49 ` James Morris
2008-02-29 13:27 ` Paul Moore
2008-02-29 13:54 ` Stephen Smalley
2008-02-29 14:13 ` Stephen Smalley
2008-02-29 14:23 ` Paul Moore
2008-02-29 16:40 ` James Antill [this message]
2008-02-29 17:03 ` Paul Moore
2008-02-29 18:41 ` Todd Miller
2008-02-29 18:58 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1204303255.11268.326.camel@code.and.org \
--to=james.antill@redhat.com \
--cc=paul.moore@hp.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.