| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return ds->originalRequest().url(); | 195 return ds->originalRequest().url(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 NOINLINE static void CrashIntentionally() { | 198 NOINLINE static void CrashIntentionally() { |
| 199 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 199 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 200 // that the signature is easier to triage in crash reports. | 200 // that the signature is easier to triage in crash reports. |
| 201 volatile int* zero = NULL; | 201 volatile int* zero = NULL; |
| 202 *zero = 0; | 202 *zero = 0; |
| 203 } | 203 } |
| 204 | 204 |
| 205 #if defined(SYZYASAN) | |
| 206 // This code triggers a C4509 warning as we're using an object with a destructor | |
| 207 // in a function with SEH. We can safely disable this as no exception will | |
| 208 // actually be thrown. | |
| 209 #pragma warning(push) | |
| 210 #pragma warning(disable: 4509) | |
| 211 NOINLINE static void CorruptMemoryBlock() { | |
| 212 // NOTE(sebmarchand): We intentionally corrupt a memory block here in order to | |
| 213 // trigger an Address Sanitizer (ASAN) error report. | |
| 214 static const int kArraySize = 5; | |
| 215 scoped_ptr<int[]> array(new int[kArraySize]); | |
| 216 // Encapsulate the invalid memory access into a try-catch statement to prevent | |
| 217 // this function from being instrumented. This way the underflow won't be | |
| 218 // detected but the corruption will (as the allocator will still be hooked). | |
| 219 __try { | |
| 220 int dummy = array[-1]--; | |
| 221 // Make sure the assignments to the dummy value aren't optimized away. | |
| 222 base::debug::Alias(&array); | |
| 223 } __except (EXCEPTION_EXECUTE_HANDLER) { | |
| 224 return; | |
| 225 } | |
| 226 } | |
| 227 #pragma warning(pop) | |
| 228 #endif | |
| 229 | |
| 230 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 205 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
| 231 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 206 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { |
| 232 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 207 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
| 233 // order to trigger an Address Sanitizer (ASAN) error report. | 208 // order to trigger an Address Sanitizer (ASAN) error report. |
| 234 static const char kCrashDomain[] = "crash"; | 209 static const char kCrashDomain[] = "crash"; |
| 235 static const char kHeapOverflow[] = "/heap-overflow"; | 210 static const char kHeapOverflow[] = "/heap-overflow"; |
| 236 static const char kHeapUnderflow[] = "/heap-underflow"; | 211 static const char kHeapUnderflow[] = "/heap-underflow"; |
| 237 static const char kUseAfterFree[] = "/use-after-free"; | 212 static const char kUseAfterFree[] = "/use-after-free"; |
| 238 #if defined(SYZYASAN) | |
| 239 static const char kCorruptHeapBlock[] = "/corrupt-heap-block"; | |
| 240 #endif | |
| 241 static const int kArraySize = 5; | 213 static const int kArraySize = 5; |
| 242 | 214 |
| 243 if (!url.DomainIs(kCrashDomain, sizeof(kCrashDomain) - 1)) | 215 if (!url.DomainIs(kCrashDomain, sizeof(kCrashDomain) - 1)) |
| 244 return; | 216 return; |
| 245 | 217 |
| 246 if (!url.has_path()) | 218 if (!url.has_path()) |
| 247 return; | 219 return; |
| 248 | 220 |
| 249 scoped_ptr<int[]> array(new int[kArraySize]); | 221 scoped_ptr<int[]> array(new int[kArraySize]); |
| 250 std::string crash_type(url.path()); | 222 std::string crash_type(url.path()); |
| 251 int dummy = 0; | 223 int dummy = 0; |
| 252 if (crash_type == kHeapOverflow) { | 224 if (crash_type == kHeapOverflow) { |
| 253 dummy = array[kArraySize]; | 225 dummy = array[kArraySize]; |
| 254 } else if (crash_type == kHeapUnderflow ) { | 226 } else if (crash_type == kHeapUnderflow ) { |
| 255 dummy = array[-1]; | 227 dummy = array[-1]; |
| 256 } else if (crash_type == kUseAfterFree) { | 228 } else if (crash_type == kUseAfterFree) { |
| 257 int* dangling = array.get(); | 229 int* dangling = array.get(); |
| 258 array.reset(); | 230 array.reset(); |
| 259 dummy = dangling[kArraySize / 2]; | 231 dummy = dangling[kArraySize / 2]; |
| 260 #if defined(SYZYASAN) | |
| 261 } else if (crash_type == kCorruptHeapBlock) { | |
| 262 CorruptMemoryBlock(); | |
| 263 #endif | |
| 264 } | 232 } |
| 265 | 233 |
| 266 // Make sure the assignments to the dummy value aren't optimized away. | 234 // Make sure the assignments to the dummy value aren't optimized away. |
| 267 base::debug::Alias(&dummy); | 235 base::debug::Alias(&dummy); |
| 268 } | 236 } |
| 269 #endif // ADDRESS_SANITIZER || SYZYASAN | 237 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 270 | 238 |
| 271 static void MaybeHandleDebugURL(const GURL& url) { | 239 static void MaybeHandleDebugURL(const GURL& url) { |
| 272 if (!url.SchemeIs(kChromeUIScheme)) | 240 if (!url.SchemeIs(kChromeUIScheme)) |
| 273 return; | 241 return; |
| (...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3201 selection_text_offset_ = offset; | 3169 selection_text_offset_ = offset; |
| 3202 selection_range_ = range; | 3170 selection_range_ = range; |
| 3203 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3171 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
| 3204 Send(new ViewHostMsg_SelectionChanged( | 3172 Send(new ViewHostMsg_SelectionChanged( |
| 3205 GetRenderWidget()->routing_id(), text, offset, range)); | 3173 GetRenderWidget()->routing_id(), text, offset, range)); |
| 3206 } | 3174 } |
| 3207 GetRenderWidget()->UpdateSelectionBounds(); | 3175 GetRenderWidget()->UpdateSelectionBounds(); |
| 3208 } | 3176 } |
| 3209 | 3177 |
| 3210 } // namespace content | 3178 } // namespace content |
| OLD | NEW |