| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/src/handle_closer_agent.h" | 5 #include "sandbox/src/handle_closer_agent.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "sandbox/src/nt_internals.h" | 8 #include "sandbox/src/nt_internals.h" |
| 9 #include "sandbox/src/win_utils.h" | 9 #include "sandbox/src/win_utils.h" |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 while (rc == STATUS_INFO_LENGTH_MISMATCH || | 85 while (rc == STATUS_INFO_LENGTH_MISMATCH || |
| 86 rc == STATUS_BUFFER_OVERFLOW) { | 86 rc == STATUS_BUFFER_OVERFLOW) { |
| 87 type_info_buffer.resize(size + sizeof(wchar_t)); | 87 type_info_buffer.resize(size + sizeof(wchar_t)); |
| 88 type_info = reinterpret_cast<OBJECT_TYPE_INFORMATION*>( | 88 type_info = reinterpret_cast<OBJECT_TYPE_INFORMATION*>( |
| 89 &(type_info_buffer[0])); | 89 &(type_info_buffer[0])); |
| 90 rc = QueryObject(handle, ObjectTypeInformation, type_info, size, &size); | 90 rc = QueryObject(handle, ObjectTypeInformation, type_info, size, &size); |
| 91 // Leave padding for the nul terminator. | 91 // Leave padding for the nul terminator. |
| 92 if (NT_SUCCESS(0) && size == type_info_buffer.size()) | 92 if (NT_SUCCESS(0) && size == type_info_buffer.size()) |
| 93 rc = STATUS_INFO_LENGTH_MISMATCH; | 93 rc = STATUS_INFO_LENGTH_MISMATCH; |
| 94 } | 94 } |
| 95 if (!NT_SUCCESS(rc)) { | 95 if (!NT_SUCCESS(rc) || !type_info->Name.Buffer) { |
| 96 ++invalid_count; | 96 ++invalid_count; |
| 97 continue; | 97 continue; |
| 98 } | 98 } |
| 99 | 99 |
| 100 --handle_count; | 100 --handle_count; |
| 101 type_info->Name.Buffer[type_info->Name.Length / sizeof(wchar_t)] = L'\0'; | 101 type_info->Name.Buffer[type_info->Name.Length / sizeof(wchar_t)] = L'\0'; |
| 102 | 102 |
| 103 // Check if we're looking for this type of handle. | 103 // Check if we're looking for this type of handle. |
| 104 HandleMap::iterator result = | 104 HandleMap::iterator result = |
| 105 handles_to_close_.find(type_info->Name.Buffer); | 105 handles_to_close_.find(type_info->Name.Buffer); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 116 return false; | 116 return false; |
| 117 if (!::CloseHandle(handle)) | 117 if (!::CloseHandle(handle)) |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 return true; | 122 return true; |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace sandbox | 125 } // namespace sandbox |
| OLD | NEW |