Fixes CVE-2021-32566 and CVE-2021-32567. (cherry picked from commit d41e86c67ff65b898be3952bf66f803a121cd083)