[systemd-devel] [PATCH 2/2] tty-ask-password-agent: fix CID 996261

David Herrmann dh.herrmann at gmail.com
Mon Nov 17 02:21:34 PST 2014


Hi

On Mon, Nov 17, 2014 at 11:20 AM, Susant Sahani <susant at redhat.com> wrote:
> On 11/17/2014 03:39 PM, David Herrmann wrote:
>>
>> Hi
>
> Hi David,
>>
>>
>> On Tue, Nov 11, 2014 at 11:33 AM, Susant Sahani <susant at redhat.com> wrote:
>>>
>>> Unchecked return value from library
>>> ---
>>>   src/tty-ask-password-agent/tty-ask-password-agent.c | 4 +++-
>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c
>>> b/src/tty-ask-password-agent/tty-ask-password-agent.c
>>> index e6dc84b..c4cd387 100644
>>> --- a/src/tty-ask-password-agent/tty-ask-password-agent.c
>>> +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
>>> @@ -376,7 +376,9 @@ static int wall_tty_block(void) {
>>>                   return -ENOMEM;
>>>
>>>           mkdir_parents_label(p, 0700);
>>> -        mkfifo(p, 0600);
>>> +        r = mkfifo(p, 0600);
>>> +        if (r < 0)
>>> +                return -errno;
>>
>>
>> What if that fifo already exists? Like if tty-ask-password-agent
>> crashes and is restarted? Maybe fix both calls, mkdir_parents_label()
>> and mkfifo(), to ignore the return value via (void).
>>
> yes I forgot that Thanks . In this case I guess
>
>    r = mkfifo(p, 0600);
>     if (r < 0) {
>        if(errno != EEXIST)
>                return -errno;
> }
>
> would be better.

Maybe just use "if (r < 0 && errno != EEXIST)"

Thanks
David


More information about the systemd-devel mailing list