about using fstat() instead of fstatat() in linux/services/proc_util.cc

58 views
Skip to first unread message

erik.s...@gmail.com

unread,
Apr 8, 2018, 12:45:41 PM4/8/18
to Chromium-dev
Hi,
When looking in the file

I see this code:

    CHECK(fstatat(proc_self_fd, de->d_name, &s, 0) == 0);
    if (S_ISDIR(s.st_mode)) {
      return true;
    }

I wonder if it wouldn't be safer to use fstat() instead of fstatat().

Instead of following the symlink and look up the path in filesystem,
you could use the file descriptor number that is written into the string 
de->d_name  and convert it to an int and then use fstat().

What do you think?

Best regards,
Erik Sjölund

Mike Frysinger

unread,
Apr 28, 2018, 9:48:28 PM4/28/18
to erik.s...@gmail.com, chromium-dev
the code is already doing the fd conversion, so it prob would be simpler to use fstatat than fstat.  want to post a CL ? :)
-mike

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/4ea57661-7b01-44c7-bfd6-a0e1a816cc95%40chromium.org.
Reply all
Reply to author
Forward
0 new messages