Research
.
Skip Search Box

SELinux Mailing List

Re: [PATCH 1/4] make newrole suid

From: Michael C Thompson <thompsmc_at_us.ibm.com>
Date: Tue, 10 Oct 2006 16:44:41 -0500


Stephen Smalley wrote:

> On Tue, 2006-10-10 at 16:27 -0400, Stephen Smalley wrote:

>> On Fri, 2006-10-06 at 17:14 -0500, Michael C Thompson wrote:
>> + fprintf(stderr,
>> + _("cannot find valid entry in the passwd file.\n"));
>> + return -1;
>> + }
>> +
>> + *pw_copy = *pw;
>> + pw = pw_copy;
>> + pw->pw_name = xstrdup(pw->pw_name);
>> + pw->pw_dir = xstrdup(pw->pw_dir);
>> + pw->pw_shell = xstrdup(pw->pw_shell);
>> +
>> + if (! (pw->pw_name && pw->pw_dir && pw->pw_shell))
>> + goto out_free;
>>

>> xstrdup by definition exits on OOM errors, so you don't have to re-test
>> here, or alternatively you don't need to use xstrdup in the first place
>> (vs. just plain strdup).
> 
> Ok, I see that in patch 3, you drop the exit call from xstrdup.  Which I
> think is a mistake - xmalloc/xstrdup-style functions typically mean
> "succeed or exit".

Right, I can see that now. I'll admit ignorance: I wasn't aware that was what the x prefix meant - I've never used that naming style before. I would rather not exit mid-code, so I'll change the use to be strdup and perform the checks.

Thanks,
Mike

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
Received on Tue 10 Oct 2006 - 17:44:46 EDT
 

Date Posted: Jan 15, 2009 | Last Modified: Jan 15, 2009 | Last Reviewed: Jan 15, 2009

 
bottom

National Security Agency / Central Security Service