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: Thu, 2 Jun 2016 17:31:25 +0530

Hello again,

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?

#1 chdir-to-check-path.patch - we change directory to see if we can
access it, print an error if we can't and return to original
directory. But then, as always, we shouldn't be sure that the path
still exists. But we use this method elsewhere.

#2 access-to-check-path.patch - access() from unistd.h can check
permissions but manual describes exactly our scenario -  "Using
access() to check if a user is authorized to, for example, open a file
before actually doing so using open(2) creates a security  hole,
because  the  user  might  exploit the short time interval between
checking and opening the file to manipulate it.  For this  reason,
the  use  of this system call should be avoided.  (In the example just
described, a safer alternative would be to temporarily switch  the
process's effective user ID to the real ID and then call open(2).)".


After patch #2, the code  i.e. use of stat(), ISDIR() and access()
sequentially is strikingly similar to the code in has_valid_path(),
files.c. Some modifications - which will make it difficult to read but
will reuse the block of code - can be made to do the same task.

Attachment: access-to-check-path.patch
Description: Text Data

Attachment: chdir-to-check-path.patch
Description: Text Data


reply via email to

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