hhvm icon indicating copy to clipboard operation
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

Open joelastpass opened this issue 16 years ago • 3 comments

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());

joelastpass avatar Jul 19 '10 19:07 joelastpass

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.

huichen avatar Jul 20 '10 00:07 huichen

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);

scottmac avatar Jul 20 '10 01:07 scottmac

Fixed in f55604ba3d916ab39354af67852583ec79038710

scottmac avatar Jul 20 '10 20:07 scottmac