Avoid buffer overflows when the sandboxee shrinks a shared buffer.

PiperOrigin-RevId: 355336078
Change-Id: I36aa106b3044cbc20b30718a12bd35d147c339c6
pull/83/head
Sandboxed API Team 2021-02-02 23:58:41 -08:00 committed by Copybara-Service
parent 0bbcb495ee
commit 637dc471ac
1 changed files with 1 additions and 1 deletions

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;
}
}