Fix packet size checks and remove bad casts.
authordv <dv@openbsd.org>
Wed, 21 Apr 2021 18:27:36 +0000 (18:27 +0000)
committerdv <dv@openbsd.org>
Wed, 21 Apr 2021 18:27:36 +0000 (18:27 +0000)
commit68388e5f0fca1620e4468bc34192ae62007e6c3e
treebc401d1a1484801de5daae973df1b2e651367de3
parentca3decda2795030c25ef6c94a1b2462b3ab210bb
Fix packet size checks and remove bad casts.

Because dhcpsz was an uninitialized ssize_t, it was possible that a
garbage "packet" would be queued on the receiving end of the virtio
network device.

Change the type to size_t and add proper checks based on it being
greater than zero. Remove the cast of ssize_t to uint64_t that also
caused garbage sizes when dhcpsz was unintialized and set at runtime
to something < 0.
usr.sbin/vmd/virtio.c
usr.sbin/vmd/virtio.h