| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 case SEEK_END: | 104 case SEEK_END: |
| 105 base_offset = string_.size(); | 105 base_offset = string_.size(); |
| 106 break; | 106 break; |
| 107 | 107 |
| 108 default: | 108 default: |
| 109 LOG(ERROR) << "Seek(): invalid whence " << whence; | 109 LOG(ERROR) << "Seek(): invalid whence " << whence; |
| 110 return -1; | 110 return -1; |
| 111 } | 111 } |
| 112 | 112 |
| 113 off_t offset_offt; | 113 off_t base_offset_offt; |
| 114 if (!AssignIfInRange(&offset_offt, base_offset)) { | 114 if (!AssignIfInRange(&base_offset_offt, base_offset)) { |
| 115 LOG(ERROR) << "Seek(): base_offset " << base_offset << " invalid for off_t"; | 115 LOG(ERROR) << "Seek(): base_offset " << base_offset << " invalid for off_t"; |
| 116 return -1; | 116 return -1; |
| 117 } | 117 } |
| 118 | 118 base::CheckedNumeric<off_t> new_offset(base_offset_offt); |
| 119 base::CheckedNumeric<off_t> new_offset(offset_offt); | |
| 120 new_offset += offset; | 119 new_offset += offset; |
| 121 if (!new_offset.IsValid()) { | 120 if (!new_offset.IsValid()) { |
| 122 LOG(ERROR) << "Seek(): new_offset invalid"; | 121 LOG(ERROR) << "Seek(): new_offset invalid"; |
| 123 return -1; | 122 return -1; |
| 124 } | 123 } |
| 125 | 124 off_t new_offset_offt = new_offset.ValueOrDie(); |
| 126 if (!AssignIfInRange(&offset_offt, new_offset.ValueOrDie())) { | 125 size_t new_offset_sizet; |
| 127 LOG(ERROR) << "Seek(): new_offset " << new_offset.ValueOrDie() | 126 if (!AssignIfInRange(&new_offset_sizet, new_offset_offt)) { |
| 127 LOG(ERROR) << "Seek(): new_offset " << new_offset_offt |
| 128 << " invalid for size_t"; | 128 << " invalid for size_t"; |
| 129 return -1; | 129 return -1; |
| 130 } | 130 } |
| 131 | 131 |
| 132 offset_ = offset_offt; | 132 offset_ = new_offset_sizet; |
| 133 | 133 |
| 134 return offset_.ValueOrDie(); | 134 return offset_.ValueOrDie(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace crashpad | 137 } // namespace crashpad |
| OLD | NEW |