hhvm
hhvm copied to clipboard
Ubuntu compilation error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT in second argument needs 3 arguments -- patch
Context diff of how to fix __open_missing_mode
diff --git a/src/util/stack_trace.cpp b/src/util/stack_trace.cpp
index 834e361..317c0e4 100644
--- a/src/util/stack_trace.cpp
+++ b/src/util/stack_trace.cpp
@@ -266,7 +266,7 @@ void StackTraceNoHeap::AddExtraLogging(const char *name, const char *value) {
void StackTraceNoHeap::log(const char *errorType, const char *tracefn,
const char *pid) const {
- int fd = ::open(tracefn, O_CREAT|O_TRUNC|O_WRONLY);
+ int fd = ::open(tracefn, S_IRUSR|S_IWUSR, O_CREAT|O_TRUNC|O_WRONLY);
if (fd < 0) return;
dprintf(fd, "Host: %s\n",Process::GetHostName().c_str());
Confirmed as a bug:
http://github.com/huichen/hiphop-php/commit/014a53d26f1f05b106249d73c023225bfcdab6ac
This could be a serious problem since using O_CREATE without specifying the third parameter may generate a file with suid/sgid mode. Triggered by -D_FORTIFY_SOURCE=2 flag on Ubuntu:
https://wiki.ubuntu.com/CompilerFlags
However mode should be the third argument.
yeah, I was looking at the man page there.
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
Fixed in f55604ba3d916ab39354af67852583ec79038710