Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: base/file_util.h

Issue 183953004: POSIX: CHECK() that file_util::ScopedFD fulfills promise. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/file_util_unittest.cc » ('j') | base/file_util_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.h
diff --git a/base/file_util.h b/base/file_util.h
index 4af6c97ad6257832f258f515de729f7f5efffc30..574c329bc1b98369a2bb862343f36a92a7bf6c54 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -416,8 +416,9 @@ typedef scoped_ptr<FILE, ScopedFILEClose> ScopedFILE;
struct ScopedFDClose {
inline void operator()(int* x) const {
if (x && *x >= 0) {
- if (IGNORE_EINTR(close(*x)) < 0)
- DPLOG(ERROR) << "close";
+ // There are security implications to not closing a file descriptor
willchan no longer on Chromium 2014/02/28 01:48:48 If it's not private and doesn't take forever to ex
jln (very slow on Chromium) 2014/02/28 02:01:21 Done. We often have schemes such as: 1. open priv
+ // properly. It's important to crash here.
+ PCHECK(0 == IGNORE_EINTR(close(*x)));
}
}
};
@@ -427,6 +428,8 @@ struct ScopedFDClose {
// need to store the FD separately and keep its memory alive). This should
// probably be called |ScopedFDCloser| or something like that.
typedef scoped_ptr<int, ScopedFDClose> ScopedFD;
+// Let new users use ScopedFDCloser already, while ScopedFD is replaced.
+typedef ScopedFD ScopedFDCloser;
#endif // OS_POSIX
#if defined(OS_LINUX)
« no previous file with comments | « no previous file | base/file_util_unittest.cc » ('j') | base/file_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698