Validate number of bytes read

Bug: chromium:1380083
Change-Id: I54a0dfb72b586638124ecc4150f0b90b9e1aa1d5
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3994208
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Joshua Peraza 2022-10-31 11:37:21 -07:00 committed by Crashpad LUCI CQ
parent 31af46b91e
commit 30ca5564f8

View File

@ -331,6 +331,11 @@ ssize_t PtraceClient::ReadUpTo(VMAddress address, size_t size, void* buffer) {
return total_read; return total_read;
} }
if (static_cast<size_t>(bytes_read) > size) {
LOG(ERROR) << "invalid size " << bytes_read;
return -1;
}
if (!LoggingReadFileExactly(sock_, buffer_c, bytes_read)) { if (!LoggingReadFileExactly(sock_, buffer_c, bytes_read)) {
return -1; return -1;
} }