<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 09/17/2014 09:58 PM, Aaron Ballman
wrote:<br>
</div>
<blockquote
cite="mid:CAAt6xTt4PsZJTzraTaAWySmP13edAg2SzA6wWBhSno_TJmA8TQ@mail.gmail.com"
type="cite">
<pre wrap="">On Wed, Sep 17, 2014 at 4:04 AM, Vassil Vassilev
<a class="moz-txt-link-rfc2396E" href="mailto:vasil.georgiev.vasilev@cern.ch"><vasil.georgiev.vasilev@cern.ch></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
I am attaching a patch addressing llvm.org/bugs/show_bug.cgi?id=20467
Vassil
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Index: lib/Frontend/CompilerInstance.cpp
===================================================================
--- lib/Frontend/CompilerInstance.cpp (revision 217432)
+++ lib/Frontend/CompilerInstance.cpp (working copy)
@@ -339,6 +339,15 @@
if (!getHeaderSearchOpts().DisableModuleHash)
llvm::sys::path::append(SpecificModuleCache,
getInvocation().getModuleHash());
+
+ // If the path is not writable we can't do anything but diagnose.
+ if (llvm::sys::fs::exists(SpecificModuleCache.str()) &&
+ !llvm::sys::fs::can_write(SpecificModuleCache.str())) {
+ SourceLocation NoLoc;
+ PP->getDiagnostics().Report(NoLoc, diag::err_module_cache_path_not_writable)
+ << SpecificModuleCache;
+ }
+
</pre>
</blockquote>
<pre wrap="">
This has TOCTOU bugs -- the path could be writable at the point of
your check, but at the point which actually attempts to create a file
on that path can still fail. I think the correct way to handle this is
to handle the failure at the point of using the path, not attempting
to fail early.</pre>
</blockquote>
Thanks! IIUC a good place to do this would be <a class="el"
href="http://clang.llvm.org/doxygen/classclang_1_1HeaderSearch.html#a99ea51bfb4bb5f4742de10c8dfde0540">clang::HeaderSearch::getModuleCachePath</a>
? Would that be acceptable?<br>
Vassil<br>
<blockquote
cite="mid:CAAt6xTt4PsZJTzraTaAWySmP13edAg2SzA6wWBhSno_TJmA8TQ@mail.gmail.com"
type="cite">
<pre wrap="">
~Aaron
</pre>
</blockquote>
<br>
</body>
</html>