Don't cast malloc(3) size to u_int.
authorcheloha <cheloha@openbsd.org>
Mon, 23 Jul 2018 23:09:37 +0000 (23:09 +0000)
committercheloha <cheloha@openbsd.org>
Mon, 23 Jul 2018 23:09:37 +0000 (23:09 +0000)
commit5a04faeb71440b1f24533a07e5230c7d4655f7da
tree325823e2cb6d8965c61413d1872f29dc3f77f2da
parent271fbe1fb320370430907e3849af5cb9ad329cd8
Don't cast malloc(3) size to u_int.

Large buffer sizes on 64-bit platforms cause the sum to wrap, leading
read(2) to fail later.

We check prior to this point that all buffer sizes are <= SSIZE_MAX.
SSIZE_MAX * 2 < SIZE_MAX on all platforms, so the addition here will
not overflow and cause a similar issue.

Discovered by tobias@ a while back.

ok deraadt millert tobias
bin/dd/dd.c