mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-21 10:12:04 +02:00
util/nvmutil: mitigate buggy libc i/o
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1480,6 +1480,12 @@ read_again:
|
|||||||
* cause an overflow. Specifications guarantee
|
* cause an overflow. Specifications guarantee
|
||||||
* this won't happen, but spec != implementation
|
* this won't happen, but spec != implementation
|
||||||
*/
|
*/
|
||||||
|
if ((size_t)rv > SSIZE_MAX) {
|
||||||
|
errno = EIO;
|
||||||
|
return -1;
|
||||||
|
/* we will not tolerate your buggy libc */
|
||||||
|
}
|
||||||
|
|
||||||
if ((size_t)rv > (len - rc) /* Prevent overflow */
|
if ((size_t)rv > (len - rc) /* Prevent overflow */
|
||||||
|| rv == 0) { /* Prevent infinite 0-byte loop */
|
|| rv == 0) { /* Prevent infinite 0-byte loop */
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user