RE: [RFC PATCH] SELinux: Cleanup the secid/secctx conversion functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Moore wrote:
> The strlcpy() implementation does a strlen() and a memcpy() call along
> with two comparisons and some trivial math.  The strcat()
> implementation does pretty much the same thing but with less
> comparisons and no additional math.  The strcpy() implementation only
> does a byte-by-byte copy which should be faster then strlcpy() even
> when one factors in an optimized memcpy() implementation due to the
> strlen() call.

The difference is that with strcat() you are also finding the length
of dest whereas which strlcpy() you only need to find the length of
src.  I really doubt it makes a measurable difference and things may
be muddied by gcc inlining some of the standard str* functions.

However, you definately do not need the final strlen(ctx) in either
case since you know that *scontext_len - 1 == strlen(ctx).

I'm not sanctioning James' abuse of strlcpy(); I think it is pointless
to try and guess which is faster without actually benchmarking it.

 - todd


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@xxxxxxxxxxxxx with
the words "unsubscribe selinux" without quotes as the message.

[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux