OLD | NEW |
1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 size_t AsanCorruptBlock() { | 1138 size_t AsanCorruptBlock() { |
1139 size_t* mem = new size_t[10]; | 1139 size_t* mem = new size_t[10]; |
1140 size_t original_value = NonInterceptedRead(&mem[-1]); | 1140 size_t original_value = NonInterceptedRead(&mem[-1]); |
1141 NonInterceptedWrite(&mem[-1], original_value + 1); | 1141 NonInterceptedWrite(&mem[-1], original_value + 1); |
1142 size_t ret = mem[0]; | 1142 size_t ret = mem[0]; |
1143 delete[] mem; | 1143 delete[] mem; |
1144 return ret; | 1144 return ret; |
1145 } | 1145 } |
1146 | 1146 |
1147 size_t AsanCorruptBlockInQuarantine() { | 1147 size_t AsanCorruptBlockInQuarantine() { |
| 1148 // This test requires the HeapCreate/HeapDestroy functions to be intercepted |
| 1149 // and so doesn't work with a Clang-instrumented binary. |
| 1150 // TODO(sebmarchand): Find another way to flush the quarantine. |
1148 HANDLE heap = ::HeapCreate(NULL, 0, 0); | 1151 HANDLE heap = ::HeapCreate(NULL, 0, 0); |
1149 size_t* mem = | 1152 size_t* mem = |
1150 static_cast<size_t*>(::HeapAlloc(heap, NULL, 10 * sizeof(size_t))); | 1153 static_cast<size_t*>(::HeapAlloc(heap, NULL, 10 * sizeof(size_t))); |
1151 size_t ret = mem[0]; | 1154 size_t ret = mem[0]; |
1152 ::HeapFree(heap, NULL, mem); | 1155 ::HeapFree(heap, NULL, mem); |
1153 | 1156 |
1154 // We modify the block after deletion so that it will cause an error to be | 1157 // We modify the block after deletion so that it will cause an error to be |
1155 // fired when the block is trimmed from the quarantine. | 1158 // fired when the block is trimmed from the quarantine. |
1156 size_t original_value = NonInterceptedRead(&mem[0]); | 1159 size_t original_value = NonInterceptedRead(&mem[0]); |
1157 NonInterceptedWrite(&mem[0], original_value + 1); | 1160 NonInterceptedWrite(&mem[0], original_value + 1); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 size_t AsanNullptrAccessNoHeapCorruptionUninstrumented() { | 1284 size_t AsanNullptrAccessNoHeapCorruptionUninstrumented() { |
1282 size_t value = 0; | 1285 size_t value = 0; |
1283 size_t* ptr = nullptr; | 1286 size_t* ptr = nullptr; |
1284 | 1287 |
1285 value = NonInterceptedRead<size_t>(ptr); | 1288 value = NonInterceptedRead<size_t>(ptr); |
1286 | 1289 |
1287 return value; | 1290 return value; |
1288 } | 1291 } |
1289 | 1292 |
1290 } // namespace testing | 1293 } // namespace testing |
OLD | NEW |