nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] segmentation fault when trying to browse to an inaccess


From: Rishabh Dave
Subject: Re: [Nano-devel] segmentation fault when trying to browse to an inaccessible directory
Date: Fri, 3 Jun 2016 20:22:46 +0530

I am asking these questions for curiosity's sake.

On Thu, Jun 2, 2016 at 9:44 PM, Mike Frysinger <address@hidden> wrote:
> On 02 Jun 2016 17:31, Rishabh Dave wrote:
>> I have figured 2 ways to solve this bug. I have tried them, patches
>> are attached. Which method/approach should I use on to fix the bug?
>
> afaict, neither of these methods actually solve the problem.
> they both suffer from TOCTOU races -- if your chdir/access passes,
> then something else changes the perms, then nano keeps going, you
> still hit the same scenario.  the only real method is to handle
> the perm errors when they show up.

By the last sentence you basically mean to go for "easier to ask for
forgiveness than permissions" instead of "look before you leap"
philosophy, right?

> the closest you could get would be to do an open(".", O_DIRECTORY)
> to get a fd, and then fchdir back to that.

Do you imply to do an open (to get a fd), then do chdir to check and
then fchdir() to get back to original directory?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]