<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 20 October 2014 15:11, Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Wed, 15.10.14 01:58, Michal Sekletar (<a href="mailto:msekleta@kemper.freedesktop.org">msekleta@kemper.freedesktop.org</a>) wrote:<br>> - mycon = context_str(bcon);<br>
> + mycon = strdup(context_str(bcon));<br>
<br>
This looks wrong!<br>
<br>
I meanm what is mycon? a string or a security_context_t? If it's the<br>
latter (which it appears to be according to its type), then it should<br>
not be assigned a string as returned by strdup(). (i figure internally<br>
they might be the same, but if they do the dance with two distinct<br>
types we should follow this non-sense here too...)<br></blockquote><div> </div>From man page:<br><br> const char * context_str(context_t con );</div><div class="gmail_quote"> context_str Return a pointer to the string value of the context_t Valid<br> until the next call to context_str or context_free for the same context_t* </div><div class="gmail_quote"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_quote">This diff seems to simply be copying the string, so that it does not become invalid.</div>
Shouldn't this be context_new() rather than strdup()?<br>
<br>
libselinux definitely has one of the most horrible APIs around! Yuck,<br>
just yuck!</blockquote><div><br></div></div><div class="gmail_quote">Confusingly, mycon is a '<span style="color:rgb(0,0,0);white-space:pre-wrap">security_context_t', which is defined as:</span></div> typedef char *security_context_t;</div><div class="gmail_extra"><br></div><div class="gmail_extra">I'm not sure what additional conversion is recommended/possible here.</div></div>