mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Fix StringFileWriter::Seek().
The final range check needs to check that the value fits in a size_t, because that’s what StringFileWriter uses for its offset_. TEST=util_test StringFileWriter.SeekInvalid R=rsesek@chromium.org Review URL: https://codereview.chromium.org/434103003
This commit is contained in:
parent
995012534e
commit
6e720f1421
@ -110,26 +110,26 @@ off_t StringFileWriter::Seek(off_t offset, int whence) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
off_t offset_offt;
|
||||
if (!AssignIfInRange(&offset_offt, base_offset)) {
|
||||
off_t base_offset_offt;
|
||||
if (!AssignIfInRange(&base_offset_offt, base_offset)) {
|
||||
LOG(ERROR) << "Seek(): base_offset " << base_offset << " invalid for off_t";
|
||||
return -1;
|
||||
}
|
||||
|
||||
base::CheckedNumeric<off_t> new_offset(offset_offt);
|
||||
base::CheckedNumeric<off_t> new_offset(base_offset_offt);
|
||||
new_offset += offset;
|
||||
if (!new_offset.IsValid()) {
|
||||
LOG(ERROR) << "Seek(): new_offset invalid";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!AssignIfInRange(&offset_offt, new_offset.ValueOrDie())) {
|
||||
LOG(ERROR) << "Seek(): new_offset " << new_offset.ValueOrDie()
|
||||
off_t new_offset_offt = new_offset.ValueOrDie();
|
||||
size_t new_offset_sizet;
|
||||
if (!AssignIfInRange(&new_offset_sizet, new_offset_offt)) {
|
||||
LOG(ERROR) << "Seek(): new_offset " << new_offset_offt
|
||||
<< " invalid for size_t";
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset_ = offset_offt;
|
||||
offset_ = new_offset_sizet;
|
||||
|
||||
return offset_.ValueOrDie();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user