Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // Copyright (c) 2006, Google Inc. |
michael@0 | 2 | // All rights reserved. |
michael@0 | 3 | // |
michael@0 | 4 | // Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | // modification, are permitted provided that the following conditions are |
michael@0 | 6 | // met: |
michael@0 | 7 | // |
michael@0 | 8 | // * Redistributions of source code must retain the above copyright |
michael@0 | 9 | // notice, this list of conditions and the following disclaimer. |
michael@0 | 10 | // * Redistributions in binary form must reproduce the above |
michael@0 | 11 | // copyright notice, this list of conditions and the following disclaimer |
michael@0 | 12 | // in the documentation and/or other materials provided with the |
michael@0 | 13 | // distribution. |
michael@0 | 14 | // * Neither the name of Google Inc. nor the names of its |
michael@0 | 15 | // contributors may be used to endorse or promote products derived from |
michael@0 | 16 | // this software without specific prior written permission. |
michael@0 | 17 | // |
michael@0 | 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 29 | |
michael@0 | 30 | // windows_frame_info.h: Holds debugging information about a stack frame. |
michael@0 | 31 | // |
michael@0 | 32 | // This structure is specific to Windows debugging information obtained |
michael@0 | 33 | // from pdb files using the DIA API. |
michael@0 | 34 | // |
michael@0 | 35 | // Author: Mark Mentovai |
michael@0 | 36 | |
michael@0 | 37 | |
michael@0 | 38 | #ifndef PROCESSOR_WINDOWS_FRAME_INFO_H__ |
michael@0 | 39 | #define PROCESSOR_WINDOWS_FRAME_INFO_H__ |
michael@0 | 40 | |
michael@0 | 41 | #include <string.h> |
michael@0 | 42 | #include <stdlib.h> |
michael@0 | 43 | |
michael@0 | 44 | #include <string> |
michael@0 | 45 | #include <vector> |
michael@0 | 46 | |
michael@0 | 47 | #include "common/using_std_string.h" |
michael@0 | 48 | #include "google_breakpad/common/breakpad_types.h" |
michael@0 | 49 | #include "common/logging.h" |
michael@0 | 50 | #include "processor/tokenize.h" |
michael@0 | 51 | |
michael@0 | 52 | namespace google_breakpad { |
michael@0 | 53 | |
michael@0 | 54 | #ifdef _WIN32 |
michael@0 | 55 | #define strtoull _strtoui64 |
michael@0 | 56 | #endif |
michael@0 | 57 | |
michael@0 | 58 | struct WindowsFrameInfo { |
michael@0 | 59 | public: |
michael@0 | 60 | enum Validity { |
michael@0 | 61 | VALID_NONE = 0, |
michael@0 | 62 | VALID_PARAMETER_SIZE = 1, |
michael@0 | 63 | VALID_ALL = -1 |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | // The types for stack_info_. This is equivalent to MS DIA's |
michael@0 | 67 | // StackFrameTypeEnum. Each identifies a different type of frame |
michael@0 | 68 | // information, although all are represented in the symbol file in the |
michael@0 | 69 | // same format. These are used as indices to the stack_info_ array. |
michael@0 | 70 | enum StackInfoTypes { |
michael@0 | 71 | STACK_INFO_FPO = 0, |
michael@0 | 72 | STACK_INFO_TRAP, // not used here |
michael@0 | 73 | STACK_INFO_TSS, // not used here |
michael@0 | 74 | STACK_INFO_STANDARD, |
michael@0 | 75 | STACK_INFO_FRAME_DATA, |
michael@0 | 76 | STACK_INFO_LAST, // must be the last sequentially-numbered item |
michael@0 | 77 | STACK_INFO_UNKNOWN = -1 |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | WindowsFrameInfo() : type_(STACK_INFO_UNKNOWN), |
michael@0 | 81 | valid(VALID_NONE), |
michael@0 | 82 | prolog_size(0), |
michael@0 | 83 | epilog_size(0), |
michael@0 | 84 | parameter_size(0), |
michael@0 | 85 | saved_register_size(0), |
michael@0 | 86 | local_size(0), |
michael@0 | 87 | max_stack_size(0), |
michael@0 | 88 | allocates_base_pointer(0), |
michael@0 | 89 | program_string() {} |
michael@0 | 90 | |
michael@0 | 91 | WindowsFrameInfo(StackInfoTypes type, |
michael@0 | 92 | uint32_t set_prolog_size, |
michael@0 | 93 | uint32_t set_epilog_size, |
michael@0 | 94 | uint32_t set_parameter_size, |
michael@0 | 95 | uint32_t set_saved_register_size, |
michael@0 | 96 | uint32_t set_local_size, |
michael@0 | 97 | uint32_t set_max_stack_size, |
michael@0 | 98 | int set_allocates_base_pointer, |
michael@0 | 99 | const string set_program_string) |
michael@0 | 100 | : type_(type), |
michael@0 | 101 | valid(VALID_ALL), |
michael@0 | 102 | prolog_size(set_prolog_size), |
michael@0 | 103 | epilog_size(set_epilog_size), |
michael@0 | 104 | parameter_size(set_parameter_size), |
michael@0 | 105 | saved_register_size(set_saved_register_size), |
michael@0 | 106 | local_size(set_local_size), |
michael@0 | 107 | max_stack_size(set_max_stack_size), |
michael@0 | 108 | allocates_base_pointer(set_allocates_base_pointer), |
michael@0 | 109 | program_string(set_program_string) {} |
michael@0 | 110 | |
michael@0 | 111 | // Parse a textual serialization of a WindowsFrameInfo object from |
michael@0 | 112 | // a string. Returns NULL if parsing fails, or a new object |
michael@0 | 113 | // otherwise. type, rva and code_size are present in the STACK line, |
michael@0 | 114 | // but not the StackFrameInfo structure, so return them as outparams. |
michael@0 | 115 | static WindowsFrameInfo *ParseFromString(const string string, |
michael@0 | 116 | int &type, |
michael@0 | 117 | uint64_t &rva, |
michael@0 | 118 | uint64_t &code_size) { |
michael@0 | 119 | // The format of a STACK WIN record is documented at: |
michael@0 | 120 | // |
michael@0 | 121 | // http://code.google.com/p/google-breakpad/wiki/SymbolFiles |
michael@0 | 122 | |
michael@0 | 123 | std::vector<char> buffer; |
michael@0 | 124 | StringToVector(string, buffer); |
michael@0 | 125 | std::vector<char*> tokens; |
michael@0 | 126 | if (!Tokenize(&buffer[0], " \r\n", 11, &tokens)) |
michael@0 | 127 | return NULL; |
michael@0 | 128 | |
michael@0 | 129 | type = strtol(tokens[0], NULL, 16); |
michael@0 | 130 | if (type < 0 || type > STACK_INFO_LAST - 1) |
michael@0 | 131 | return NULL; |
michael@0 | 132 | |
michael@0 | 133 | rva = strtoull(tokens[1], NULL, 16); |
michael@0 | 134 | code_size = strtoull(tokens[2], NULL, 16); |
michael@0 | 135 | uint32_t prolog_size = strtoul(tokens[3], NULL, 16); |
michael@0 | 136 | uint32_t epilog_size = strtoul(tokens[4], NULL, 16); |
michael@0 | 137 | uint32_t parameter_size = strtoul(tokens[5], NULL, 16); |
michael@0 | 138 | uint32_t saved_register_size = strtoul(tokens[6], NULL, 16); |
michael@0 | 139 | uint32_t local_size = strtoul(tokens[7], NULL, 16); |
michael@0 | 140 | uint32_t max_stack_size = strtoul(tokens[8], NULL, 16); |
michael@0 | 141 | int has_program_string = strtoul(tokens[9], NULL, 16); |
michael@0 | 142 | |
michael@0 | 143 | const char *program_string = ""; |
michael@0 | 144 | int allocates_base_pointer = 0; |
michael@0 | 145 | if (has_program_string) { |
michael@0 | 146 | program_string = tokens[10]; |
michael@0 | 147 | } else { |
michael@0 | 148 | allocates_base_pointer = strtoul(tokens[10], NULL, 16); |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | return new WindowsFrameInfo(static_cast<StackInfoTypes>(type), |
michael@0 | 152 | prolog_size, |
michael@0 | 153 | epilog_size, |
michael@0 | 154 | parameter_size, |
michael@0 | 155 | saved_register_size, |
michael@0 | 156 | local_size, |
michael@0 | 157 | max_stack_size, |
michael@0 | 158 | allocates_base_pointer, |
michael@0 | 159 | program_string); |
michael@0 | 160 | } |
michael@0 | 161 | |
michael@0 | 162 | // CopyFrom makes "this" WindowsFrameInfo object identical to "that". |
michael@0 | 163 | void CopyFrom(const WindowsFrameInfo &that) { |
michael@0 | 164 | type_ = that.type_; |
michael@0 | 165 | valid = that.valid; |
michael@0 | 166 | prolog_size = that.prolog_size; |
michael@0 | 167 | epilog_size = that.epilog_size; |
michael@0 | 168 | parameter_size = that.parameter_size; |
michael@0 | 169 | saved_register_size = that.saved_register_size; |
michael@0 | 170 | local_size = that.local_size; |
michael@0 | 171 | max_stack_size = that.max_stack_size; |
michael@0 | 172 | allocates_base_pointer = that.allocates_base_pointer; |
michael@0 | 173 | program_string = that.program_string; |
michael@0 | 174 | } |
michael@0 | 175 | |
michael@0 | 176 | // Clears the WindowsFrameInfo object so that users will see it as though |
michael@0 | 177 | // it contains no information. |
michael@0 | 178 | void Clear() { |
michael@0 | 179 | type_ = STACK_INFO_UNKNOWN; |
michael@0 | 180 | valid = VALID_NONE; |
michael@0 | 181 | program_string.erase(); |
michael@0 | 182 | } |
michael@0 | 183 | |
michael@0 | 184 | StackInfoTypes type_; |
michael@0 | 185 | |
michael@0 | 186 | // Identifies which fields in the structure are valid. This is of |
michael@0 | 187 | // type Validity, but it is defined as an int because it's not |
michael@0 | 188 | // possible to OR values into an enumerated type. Users must check |
michael@0 | 189 | // this field before using any other. |
michael@0 | 190 | int valid; |
michael@0 | 191 | |
michael@0 | 192 | // These values come from IDiaFrameData. |
michael@0 | 193 | uint32_t prolog_size; |
michael@0 | 194 | uint32_t epilog_size; |
michael@0 | 195 | uint32_t parameter_size; |
michael@0 | 196 | uint32_t saved_register_size; |
michael@0 | 197 | uint32_t local_size; |
michael@0 | 198 | uint32_t max_stack_size; |
michael@0 | 199 | |
michael@0 | 200 | // Only one of allocates_base_pointer or program_string will be valid. |
michael@0 | 201 | // If program_string is empty, use allocates_base_pointer. |
michael@0 | 202 | bool allocates_base_pointer; |
michael@0 | 203 | string program_string; |
michael@0 | 204 | }; |
michael@0 | 205 | |
michael@0 | 206 | } // namespace google_breakpad |
michael@0 | 207 | |
michael@0 | 208 | |
michael@0 | 209 | #endif // PROCESSOR_WINDOWS_FRAME_INFO_H__ |