Avoid buffer overflows when the sandboxee shrinks a shared buffer.

PiperOrigin-RevId: 355336078
Change-Id: I36aa106b3044cbc20b30718a12bd35d147c339c6
This commit is contained in:
Sandboxed API Team 2021-02-02 23:58:41 -08:00 committed by Copybara-Service
parent 0bbcb495ee
commit 637dc471ac

View File

@ -113,7 +113,7 @@ class Array : public Var, public Pointable {
} else {
new_addr = malloc(size);
if (new_addr) {
memcpy(new_addr, arr_, total_size_);
memcpy(new_addr, arr_, std::min(size, total_size_));
buffer_owned_ = true;
}
}