OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/linux/syscall_broker/broker_file_permission.h" | 5 #include "sandbox/linux/syscall_broker/broker_file_permission.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 // O_SYNC can be defined as (__O_SYNC|O_DSYNC) | 119 // O_SYNC can be defined as (__O_SYNC|O_DSYNC) |
120 #ifdef O_DSYNC | 120 #ifdef O_DSYNC |
121 const int kSyncFlag = O_SYNC & ~O_DSYNC; | 121 const int kSyncFlag = O_SYNC & ~O_DSYNC; |
122 #else | 122 #else |
123 const int kSyncFlag = O_SYNC; | 123 const int kSyncFlag = O_SYNC; |
124 #endif | 124 #endif |
125 | 125 |
126 const int kNumberOfBitsInOAccMode = 2; | 126 const int kNumberOfBitsInOAccMode = 2; |
127 COMPILE_ASSERT(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1), | 127 static_assert(O_ACCMODE == ((1 << kNumberOfBitsInOAccMode) - 1), |
128 number_of_bits); | 128 "incorrect number of bits"); |
129 // check every possible flag and act accordingly. | 129 // check every possible flag and act accordingly. |
130 // Skipping AccMode bits as they are present in every case. | 130 // Skipping AccMode bits as they are present in every case. |
131 for (int i = kNumberOfBitsInOAccMode; i < 32; i++) { | 131 for (int i = kNumberOfBitsInOAccMode; i < 32; i++) { |
132 int flag = 1 << i; | 132 int flag = 1 << i; |
133 switch (flag) { | 133 switch (flag) { |
134 case O_APPEND: | 134 case O_APPEND: |
135 case O_ASYNC: | 135 case O_ASYNC: |
136 case O_DIRECT: | 136 case O_DIRECT: |
137 case O_DIRECTORY: | 137 case O_DIRECTORY: |
138 #ifdef O_DSYNC | 138 #ifdef O_DSYNC |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/..")); | 253 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/..")); |
254 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/../bad")); | 254 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/bad/../bad")); |
255 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/../bad")); | 255 EXPECT_FALSE(BrokerFilePermissionTester::ValidatePath("/../bad")); |
256 } | 256 } |
257 | 257 |
258 } // namespace | 258 } // namespace |
259 | 259 |
260 } // namespace syscall_broker | 260 } // namespace syscall_broker |
261 | 261 |
262 } // namespace sandbox | 262 } // namespace sandbox |
OLD | NEW |