mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
mkhtemp rand: fix theoretical integer overflow
extremely theoretical, with a T. T for theoretical. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -126,7 +126,7 @@ mkrstr(size_t n) /* emulates spkmodem-decode */
|
||||
if (n == 0)
|
||||
err_no_cleanup(0, EPERM, "mkrbuf: zero-byte request");
|
||||
|
||||
if (n == SIZE_MAX)
|
||||
if (n >= SIZE_MAX - 1)
|
||||
err_no_cleanup(0, EOVERFLOW, "mkrbuf: overflow");
|
||||
|
||||
if (if_err((s = mkrbuf(n + 1)) == NULL, EFAULT))
|
||||
@@ -149,6 +149,9 @@ mkrbuf(size_t n)
|
||||
if (n == 0)
|
||||
err_no_cleanup(0, EPERM, "mkrbuf: zero-byte request");
|
||||
|
||||
if (n >= SIZE_MAX - 1)
|
||||
err_no_cleanup(0, EOVERFLOW, "integer overflow in mkrbuf");
|
||||
|
||||
if ((buf = malloc(n)) == NULL)
|
||||
err_no_cleanup(0, ENOMEM, "mkrbuf: malloc");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user