Check overflow in init(8).
Instead of multiplying new_length
by 2, which could cause a multiplication overflow, multiply sizeof(struct harddisk*)
by 2.
This makes reallocarray
perform an additional overflow check - namely that new_length * 2
does not overflow.
sizeof(struct harddisk*)
is not likely to be more than SIZE_MAX/2
, so this is probably safe.