[systemd-devel] [systemd-commits] src/shared
Daurnimator
quae at daurnimator.com
Mon Oct 20 12:20:29 PDT 2014
On 20 October 2014 15:11, Lennart Poettering <lennart at poettering.net> wrote:
> On Wed, 15.10.14 01:58, Michal Sekletar (msekleta at kemper.freedesktop.org)
> wrote:
> > - mycon = context_str(bcon);
> > + mycon = strdup(context_str(bcon));
>
> This looks wrong!
>
> I meanm what is mycon? a string or a security_context_t? If it's the
> latter (which it appears to be according to its type), then it should
> not be assigned a string as returned by strdup(). (i figure internally
> they might be the same, but if they do the dance with two distinct
> types we should follow this non-sense here too...)
>
>From man page:
const char * context_str(context_t con );
context_str Return a pointer to the string value of the context_t Valid
until the next call to context_str or context_free for the
same context_t*
This diff seems to simply be copying the string, so that it does not become
> invalid.
> Shouldn't this be context_new() rather than strdup()?
>
> libselinux definitely has one of the most horrible APIs around! Yuck,
> just yuck!
Confusingly, mycon is a 'security_context_t', which is defined as:
typedef char *security_context_t;
I'm not sure what additional conversion is recommended/possible here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20141020/5ab38cf4/attachment.html>
More information about the systemd-devel
mailing list